Announcement

Collapse
No announcement yet.

DEBUG: Reimplementing the patch SLIC functions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DEBUG: Reimplementing the patch SLIC functions

    I said that I wanted to work on SLIC and so I thought that I should begin by reimplimenting all the missing functions.

    Martin has already beaten me to the first step by inserting stubs for them all, but there's quite a lot to fill in yet.

    So, I think we should coordinate our efforts so as not to duplicate work done by others. Post your requests for implementations, as well as your actual implementations, here.

    For the moment I intend to simply work through those which I have seen used in mods already, filling them in as best I can. Testing them is obviously a much bigger job, and I doubt that I will do it sufficiently thoroughly. Does anyone have a good idea as to how testing might be made more easy. I was thinking that some knd of SLIC debugging system might be helpful, but I'm not sure what form it should take.

    Comments welcome.

  • #2
    Looking a little closer it seems that Martin has already filled in the details of some of the most important ones too . He has been busy.

    Comment


    • #3
      For starters here are some functions about wonders, successfully compiled but untested:
      Code:
      // JJB filled this function
      SFN_ERROR Slic_PlayerHasWonder::Call(SlicArgList *args)
      {
      	if(args->m_numArgs != 2)
      		return SFN_ERROR_NUM_ARGS;
      
      	sint32 pl;
      	if(!args->GetPlayer(0, pl))
      		return SFN_ERROR_TYPE_ARGS;
      
      	if(pl < 0 || pl >= k_MAX_PLAYERS)
      		return SFN_ERROR_OUT_OF_RANGE;
      
      	if(!g_player[pl]) {
      		return SFN_ERROR_DEAD_PLAYER;
      	}
      	
      	sint32 wonder;
      
      	if(!args->GetInt(1, wonder)) {
      		return SFN_ERROR_TYPE_ARGS;
      	}
      
      	sint32 owner = wonderutil_GetOwner(wonder);
      
      	if (owner == pl)
      		m_result.m_int = 1;
      	else
      		m_result.m_int = 0;
      
      	return SFN_ERROR_OK;
      }
      
      // JJB filled this function
      SFN_ERROR Slic_WonderOwner::Call(SlicArgList *args)
      {
      	if(args->m_numArgs != 1)
      		return SFN_ERROR_NUM_ARGS;
      
      	sint32 wonder;
      
      	if(!args->GetInt(0, wonder)) {
      		return SFN_ERROR_TYPE_ARGS;
      	}
      
      	sint32 owner = wonderutil_GetOwner(wonder);
      
      	if (owner == PLAYER_INDEX_INVALID)
      		m_result.m_int = -1;
      	else
      		m_result.m_int = owner;
      
      	return SFN_ERROR_OK;
      }
      
      // JJB filled this function
      SFN_ERROR Slic_CityHasWonder::Call(SlicArgList *args)
      {
      	if(args->m_numArgs != 2)
      		return SFN_ERROR_NUM_ARGS;
      
      	Unit city;
      
      	if(!args->GetCity(0, city))
      		return SFN_ERROR_TYPE_BUILTIN;
      
      	sint32 wonder;
      
      	if(!args->GetInt(1, wonder)) {
      		return SFN_ERROR_TYPE_ARGS;
      	}
      
      	if (city.GetCityData()->GetBuiltWonders() & ((uint64)1 << wonder)) {
      		m_result.m_int = 1;
      		return SFN_ERROR_OK;
      	}
      
      	m_result.m_int = 0;
      	return SFN_ERROR_OK;
      }

      Comment


      • #4
        Originally posted by J Bytheway
        Testing them is obviously a much bigger job, and I doubt that I will do it sufficiently thoroughly. Does anyone have a good idea as to how testing might be made more easy.
        Of course there is a more easy way to test it:

        Add this to your scen_str.txt in your ..\ctp2_data\english\gamedata\ folder:

        TEST_MESSAGE_FOR_MAE "0: {int0}, 1: {int1}, 2: {int2}, 3: {int3}, 4: {int4}, 5: {int5}, 6: {int6}, 7: {int7}, 8: {int8}, 9: {int9}, 10: {int10}, 11: {int11}, 12: {int12}, 13: {int13}, 14: {int14}, 15: {int15}, 16: {int16}, 17: {int17}, 18: {int18}, 19: {int19}, 20: {int20} 21: {int21}, 22: {int22}, 23: {int23}, 24: {int24}, 25: {int25}, 26: {int26}, 27: {int27}, 28: {int28}, 29: {int29}"
        And put into your scenario\.slc in your ..\ctp2_data\default\gamedata\ folder: (I know John you already know this but I also explain it to those who aren't so familiar with the CTP2 file structure.)

        Code:
        int_t int0;
        int_t int1;
        int_t int2;
        int_t int3;
        int_t int4;
        int_t int5;
        int_t int6;
        int_t int7;
        int_t int8;
        int_t int9;
        int_t int10;
        int_t int11;
        int_t int12;
        int_t int13;
        int_t int14;
        int_t int15;
        int_t int16;
        int_t int17;
        int_t int18;
        int_t int19;
        int_t int20;
        int_t int21;
        int_t int22;
        int_t int23;
        int_t int24;
        int_t int25;
        int_t int26;
        int_t int27;
        int_t int28;
        int_t int29;
        
        HandleEvent(ArmyClicked)'MG_Testing'post{
        }
        
        HandleEvent(CityClicked)'MG_TestingH'post{
        }
        
        MessageBox'MGMAETestMessage'{
        	Text(ID_TEST_MESSAGE_FOR_MAE);
        	Duration(1);
        	MessageType("GIFT");
        }
        You just need to fill the Event handlers that asign the return values of your functions to some of the ints. And add the message box call to the handler and you should see something. Alternativly you can use the files from the attachment, there I have included lots of examples how to test slic code in general. Of course the stuff is outcommented.

        -Martin
        Attached Files
        Civ2 military advisor: "No complaints, Sir!"

        Comment

        Working...
        X