Page 6 of 10 FirstFirst ... 3 4 5 6 7 8 9 ... LastLast
Results 151 to 180 of 278

Thread: E's Source Code attempts

  1. #151
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,254
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    September 19, 2014
    Local Time
    04:47

    Post

    Originally posted by E
    and it seems that its the same crash
    Code:
      0x004cb9c0  [?KillUnitsOverBudget@MilitaryReadiness@@QAEXJAAV?$DynamicArray@VArmy@@@@J@Z + 0x340]
      0x004841b4  [??0BattleEvent@@QAE@XZ + 0x4]
      0x00501eb3  [?SaveAdvances@MapFile@@QAE_NPAU_iobuf@@@Z + 0x1c3]
      0x00482e1b  [?armyevent_Initialize@@YAXXZ + 0x1eb]
      0x00482eb3  [?armyevent_Initialize@@YAXXZ + 0x283]
      0x0084085d  [?g_const_token_data@@3PAUTokenData@@A + 0xc0c5]
      0x005ba5af  [?Serialize@UnitRecord@@QAEXAAVCivArchive@@@Z + 0x49f]
      0x005ba546  [?Serialize@UnitRecord@@QAEXAAVCivArchive@@@Z + 0x436]
      0x005bb20a  [?Serialize@UnitRecord@@QAEXAAVCivArchive@@@Z + 0x10fa]
      0x005b8e64  [?ResolveDBReferences@TerrainRecord@@QAEXXZ + 0xa4]
      0x005bb068  [?Serialize@UnitRecord@@QAEXAAVCivArchive@@@Z + 0xf58]
      0x005bb00b  [?Serialize@UnitRecord@@QAEXAAVCivArchive@@@Z + 0xefb]
      0x0040efe1  [??0ActorPath@@QAE@JJJJ@Z + 0x51]
      0x00407db0  [?InitializeAppDB@CivApp@@QAEJAAVCivArchive@@@Z + 0xa0]
      0x00407827  [?New@?$tech_Memory@ULink@?$tech_WLList@PAD@@@@QAEPAULink@?$tech_WLList@PAD@@XZ + 0x7]
      0x008adf5c  [?g_mapTokenData@@3PAUTokenData@@A + 0x19564]
      0x7c816d4f  [__onexitbegin + 0x7bd591b7]
    should I try what ctp2linuxfan suggested? or am I missing something?
    E, do you use the debug version for testing? The debug version should delete any files in the log folder, including any crasht.txts. The debug version generates a log files with a lot of bits of information about the game including call stacks in the case of asserts and exceptions.

    Look at these call stacks. And of course ctp2linuxfan's idea should be considerated when you got the debug version running and you still have no idea.

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

  2. #152
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    How do I get a debug version? do I have to compile a debug version or is there some setting?

    If I do ctp2linuxfan's suggestion, is it just renaming it, because I havent seen how events are called. when I do a search they don't come up.

    Also I've been figuring out the diplomacy ldl when I reach point I don't understand in this hidden nationality code. Pretty soon I'll have a few questions about splitting te tabs into listboxes and putting treaties in both.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  3. #153
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,254
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    September 19, 2014
    Local Time
    04:47

    Post

    Originally posted by E
    How do I get a debug version? do I have to compile a debug version or is there some setting?
    I thought so that you would have this question sooner or later.

    Unfortunately I don't have VS6 here and VS.NET is a little bit diffrent. Somewere in the menu there is a an option to set the current configuration and there is something to manage your configuration (add, modify, etc.). I know this can be a little bit confusing, especially as you can only select from the configuartion setting menu the configuartion.

    There you select the debug configuration and then you conpile the whole code again. The compile progress report will start then stating that you are compiling the debug version and not the final version.

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

  4. #154
    Fromafar
    Prince
    Join Date
    25 May 2003
    Posts
    622
    Country
    This is Fromafar's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 19, 2014
    Local Time
    05:47
    In MSVC6, go to the Build menu, and select "Set Active Configuration". You should get a pop-up window, on which you have to select the "ctp2 - Win32 Debug" configuration.
    Don't forget to reset the configuration to "ctp2 - Win32 Final" when you are generating a (faster/optimised) version for distribution.

  5. #155
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    Thanks Martin and Fromafar,

    I made the debug and tried out my code and
    when I attacked with my Sneak Attack(SA) pirateship versus a defender's stack of a galley (non-SA) and a defender's pirate ship (is SA) I got a gameobj.cpp error

    it said no such ID 805306348

    then ctd


    I have no idea what this means, i go this from civ3log.txt it looks like the relevant part:



    Code:
           Unit.cpp@178 : Unit::RemoveAllReferences: id: 268435476     Player.cpp@1438: Player::RemoveUnitReference(10000014, 2)
        ObjPool.cpp@175 : ObjPool: Deleting object id d0000014
        ObjPool.cpp@175 : ObjPool: Deleting object id 10000014
           Unit.cpp@178 : Unit::RemoveAllReferences: id: 268435477     Player.cpp@1438: Player::RemoveUnitReference(10000015, 2)
        ObjPool.cpp@175 : ObjPool: Deleting object id d0000015
        ObjPool.cpp@175 : ObjPool: Deleting object id 10000015
        GameObj.cpp@124 : No such id d0000014
       c3errors.cpp@183 : Error: GameObj.cpp Error, No such id -805306348
        c3debug.cpp@320 : Assertion (FALSE) Failed in File:F:\SVN-Code\trunk\ctp2_code\ctp\ctp2_utils\c3errors.cpp, Line:59
        c3debug.cpp@323 : Stack Trace: '  0x00457070  [(unknown) + 0x0]
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  6. #156
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,254
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    September 19, 2014
    Local Time
    04:47

    Post

    Originally posted by E
    I have no idea what this means, i go this from civ3log.txt it looks like the relevant part:
    [/code]
    No, this isn't the relevant part at least not of it. The stack trace below the Assertion (FALSE) is the relevant part.

    But what is this:

    Code:
    c3debug.cpp@323 : Stack Trace: '  0x00457070  [(unknown) + 0x0]
    Why is the stack trace unknown? What did you do with the *.exe?

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

  7. #157
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    Originally posted by Martin Gühmann


    No, this isn't the relevant part at least not of it. The stack trace below the Assertion (FALSE) is the relevant part.

    But what is this:

    Code:
    c3debug.cpp@323 : Stack Trace: '  0x00457070  [(unknown) + 0x0]
    Why is the stack trace unknown? What did you do with the *.exe?

    -Martin
    the only thing i did with the exe is open the ctp2 debug.exe. I did not use a final ctp2. maybe it became unknown because it basically crashed, well it minimized and then had the endobj,cpp error.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  8. #158
    J Bytheway
    Emperor J Bytheway's Avatar
    Join Date
    02 Jul 2001
    Location
    England
    Posts
    3,826
    Country
    This is J Bytheway's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 19, 2014
    Local Time
    04:47
    I suspect that
    Code:
    GameObj.cpp@124 : No such id d0000014
    might be an indicator of your problem.

  9. #159
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    Thanks J,

    do you know what that means though? the unit id? is it the sneak attack flag? i'm not sure how to read this data...
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  10. #160
    Fromafar
    Prince
    Join Date
    25 May 2003
    Posts
    622
    Country
    This is Fromafar's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 19, 2014
    Local Time
    05:47
    Code:
    Unit.cpp@178 : Unit::RemoveAllReferences: id: 268435476     
    Player.cpp@1438: Player::RemoveUnitReference(10000014, 2)
    ObjPool.cpp@175 : ObjPool: Deleting object id d0000014
    ObjPool.cpp@175 : ObjPool: Deleting object id 10000014
    tells you that the unit labelled "d0000014" has been removed from the game.

    Code:
    GameObj.cpp@124 : No such id d0000014
    c3errors.cpp@183 : Error: GameObj.cpp Error, No such id -805306348
    means that you are trying to do something with this unit after it has been removed.

    This is a common error. You will get this lots of times in "post-action" Slic and game event handlers. In these cases, you have to verify that the unit is still valid, because it may have been killed in a battle.

  11. #161
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    thanks fromafar,

    i guess my next question would be how do i fix that. i guess my sneak attack code is trying to send a message after the defenders are beaten in a stack, or is trying to do a stack check. I think I might have to try something from the civilian code above aftermath

    Code:
    	if (u.GetDBRec()->GetCivilian() == true) {
    		if (not_at_war &&
    			army.Num() == 1
    but i'm not sure that will sove the stack issue. all I wantt o do is have it declare war if a defenders stack has one SA unit and one non-SA unit...
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  12. #162
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,254
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    September 19, 2014
    Local Time
    04:47

    Post

    Originally posted by E
    the only thing i did with the exe is open the ctp2 debug.exe. I did not use a final ctp2. maybe it became unknown because it basically crashed, well it minimized and then had the endobj,cpp error.
    My suspicion is that you moved the executable from its creation directory to some other location. That would explain why the crash.txt you posted contains nonsense. And of course it also explains the stack trace with unknown methods/functions. And by the way before I can give you more advice, you have to fix the problem with the stack trace first.

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

  13. #163
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    when I compile an exe it compiles into my SVN/ctp folder thenI move it to one of my ctp2 game folders and I execute it from there. I've played may games this way. should I compile it so it appears in the game folder then?
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  14. #164
    Fromafar
    Prince
    Join Date
    25 May 2003
    Posts
    622
    Country
    This is Fromafar's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 19, 2014
    Local Time
    05:47
    No, moving the exe is OK. Just make sure that you move the map file to the same place. I guess you now have a map file of an older version there, which causes your crash logs to become useless.

    In cases where you can not be sure of the unit validity, you have to check it before accessing it. Something like:
    Code:
    if (u.IsValid())
    {
        // Now you know that the unit is valid.
        if (u.GetDBRec()->GetCivilian())
        [...]
    }

  15. #165
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,254
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    September 19, 2014
    Local Time
    04:47

    Post

    Originally posted by E
    when I compile an exe it compiles into my SVN/ctp folder thenI move it to one of my ctp2 game folders and I execute it from there. I've played may games this way. should I compile it so it appears in the game folder then?
    And that's the problem. Well Fromafar is right about that it is sufficient to move the executable with the map file, but however this methods bears some disadvantages.

    First thing is that you have to copy always the the executable and the map file to the other directory whenever you compile the program. And that holds also for all the text files you get from the repository. Of course except if the ctp2_data directory you use is part of your working copy. You can always forget to copy something.

    Second you can't run the game from the IDE, it is so simple if you do just press Ctrl+F5 and the game is compiled and run. Just two keys.

    And with this setup you can't use the debugger, at least I don't know how, but certainly you can't just press F5.

    So it is better to to copy all the art, sound and text files that aren't already part of your working copy to your working copy and run the game from your working copy.

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

  16. #166
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    My latest testing of the SneakAttack, I turned the battleviews back on to see ow the stack was handled and it seems that the crash occurs because any (attacker or defender) SneakAttack unit causes a crash. The valid code didnt seem to help...

    I think the issue is that Regardevent only tracks an attack event but not the killing of a unit. I'm thinking of taking the KillUnitRegard event code for Civilian and adding something like it to the BattleAftermath and call CAUSES but as I was exploring that I got stumped on how does the game know when to call events? I did a search on the event name and even the file name and it only turned up the regardevent. Can anyone explain how the game knows when to trigger an event and what file does that?


    thanks...
    Last edited by Ekmek; December 4, 2005 at 21:46.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  17. #167
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    ok I got stacks handled and theattcker stuff, but when a non-SA attacker beats an SA defender its still triggering the war so I have to work on that. for some reason army and the AllSneakAttack isnt working out... but I'll try a few things

    Code:
    	bool AllDefSneakAttack = true;
    	bool AllSneakAttack = true;
    	sint32 i;
    	if(army.IsValid()) {
    		for(i = 0; i < army.Num(); i++) {
    			if(!army[i].GetDBRec()->GetSneakAttack()){
    				AllSneakAttack = false;
    				break;
    			}
    		}
    	}
    	if(!AllSneakAttack){
    ////still didnt work need to find some way...
    
    		sint32 j;
    		if(td.IsValid()) {
    		CellUnitList stack;
    		g_theWorld->GetArmy(td.RetPos(), stack);
    
    			for(j = 0; j < stack.Num(); j++) {
    				if(!stack[j].GetDBRec()->GetSneakAttack()){
    					AllDefSneakAttack = false;
    					break;
    				}
    			}
    		}
    	}
    		if(!AllDefSneakAttack){
    			Diplomat & defending_diplomat = Diplomat::GetDiplomat(defense_owner);
    			defending_diplomat.LogViolationEvent(attack_owner, PROPOSAL_TREATY_CEASEFIRE);
    	}
    Last edited by Ekmek; December 6, 2005 at 23:34.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  18. #168
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    Well the code for the attcker works, stacks and all. For the defender I tried several things I tried to do a check after !AllSneakAttack and I also tried to do it right after the GetSnakAttack. BUt in both cases whenever I tried to add an additional check of the defender it seemed like the code just ignored and would skip the logviolation alltogether. I thikits because I added a td.IsValid but then checked the sneakattck and then it would skip. What am I doing wrong.


    Code:
    	bool AllSneakAttack = true;
    	sint32 i;
    	if(army.IsValid()) {
    		for(i = 0; i < army.Num(); i++) {
    			if(!army[i].GetDBRec()->GetSneakAttack()){
    					AllSneakAttack = false;
    //tried here				
    	break;
    			}
    		}
    	}
    	
    	
    	if(!AllSneakAttack){
    //and tried here
    			Diplomat & defending_diplomat = Diplomat::GetDiplomat(defense_owner);
    			defending_diplomat.LogViolationEvent(attack_owner, PROPOSAL_TREATY_CEASEFIRE);
    
    	}
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  19. #169
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,254
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    September 19, 2014
    Local Time
    04:47

    Post

    First thing to do: Get the indention right. How often do I have to repeat this?

    Actually I shouldn't give you this piece of information without seeing fixed the indention first. but anyway, to your problem, I think you only check the attacker army but you don't check the defender army and that might be located somewhere else.

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

  20. #170
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    thanks,

    I've actually gotten in a good habit of indention, its just when i post on apolyton and delete some of my other comments/notes it gets all messed and the tabbing doesnt work the same on this site.

    As for checking the attacker army. Thats the weird part, the code only defines Army army then goes into unit ta and unit td (attacker and defender respectively). elsewhere in the code is doesn't address whether army is only for the attacker or defender.



    EDIT: ok i think i know what i got to do now.
    Last edited by Ekmek; December 9, 2005 at 17:48.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  21. #171
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    well it still doesnt check the defender, I tried this:

    Code:
    STDEHANDLER(BattleAftermathRegardEvent)
    {
    	Army army;
    	Army darmy; //added by E to check defender army
    	MapPoint pos;
    	Unit ta;
    	Unit td;
    	sint32 attack_owner, defense_owner;
    
    	
    	args->GetArmy(0, army);
    
    	args->GetArmy(1, darmy);
    
    	if(!args->GetPos(0, pos))
    		return GEV_HD_Continue;
    
    	args->GetUnit(0, ta);
    	args->GetUnit(1, td);
    
    	if(!args->GetPlayer(0, attack_owner))
    		return GEV_HD_Continue;
    
    	if(!args->GetPlayer(1, defense_owner))
    		return GEV_HD_Continue;
    
    
    	bool AllSneakAttack = true;
    
    	sint32 i;
    	if(army.IsValid()) {
    		for(i = 0; i < army.Num(); i++) {
    			if(!army[i].GetDBRec()->GetSneakAttack()){
    				if(darmy.IsValid()) {
    					if(!darmy[i].GetDBRec()->GetSneakAttack()){
    						AllSneakAttack = false;
    						break;
    					}
    				}
    			}	
    		}
    	}
    
    	if(!AllSneakAttack){
    			Diplomat & defending_diplomat = Diplomat::GetDiplomat(defense_owner);
    			defending_diplomat.LogViolationEvent(attack_owner, PROPOSAL_TREATY_CEASEFIRE);
    	}
    
    	if(AllSneakAttack){
    			return GEV_HD_Continue;
    	}
    
    
    	return GEV_HD_Continue;
    }
    and even simplified it further by trying this..

    Code:
    STDEHANDLER(BattleAftermathRegardEvent)
    {
    	Army army;
    	MapPoint pos;
    	Unit ta;
    	Unit td;
    	sint32 attack_owner, defense_owner;
    
    	
    	args->GetArmy(0, army);
    
    	args->GetArmy(1, army);  //added by E to check defender army
    
    	if(!args->GetPos(0, pos))
    		return GEV_HD_Continue;
    
    	args->GetUnit(0, ta);
    	args->GetUnit(1, td);
    
    	if(!args->GetPlayer(0, attack_owner))
    		return GEV_HD_Continue;
    
    	if(!args->GetPlayer(1, defense_owner))
    		return GEV_HD_Continue;
    
    
    	bool AllSneakAttack = true;
    
    	sint32 i;
    	if(army.IsValid()) {
    		for(i = 0; i < army.Num(); i++) {
    			if(!army[i].GetDBRec()->GetSneakAttack()){
    				AllSneakAttack = false;
    				break;
    
    			}	
    		}
    	}
    
    	if(!AllSneakAttack){
    			Diplomat & defending_diplomat = Diplomat::GetDiplomat(defense_owner);
    			defending_diplomat.LogViolationEvent(attack_owner, PROPOSAL_TREATY_CEASEFIRE);
    	}
    
    
    
    	return GEV_HD_Continue;
    }
    I also tried the first set up with the defender outside of the 'for' in its own and still it would ignire the war declaration, it appears to ignore the (!SneakAttack) whenever I put the defender in it.

    I think I got the defender check down but not sure why its bypassing the logvio. what am i doing wrong?
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  22. #172
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,254
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    September 19, 2014
    Local Time
    04:47

    Post

    Originally posted by E
    I've actually gotten in a good habit of indention, its just when i post on apolyton and delete some of my other comments/notes it gets all messed and the tabbing doesnt work the same on this site.
    I see. But you can bypass the problem by copying one of the tabs you have in the post-reply box. However you should not do this otherwise I cannot see what is in your working copy and that might be something else you post here. And to have more bits of information available is always better then to less.

    However for your problem, your second code is better than you first code. The second code contains less baloney than the first code. In the second code you retrieve the army twice however this doesn't work since only one army is passed to the event. And it would work anyway since the units at the defender position aren't necessary grouped. So retrieving an army from that postion doesn't help, so you have to cycle through all units at the defender's position. And check the required property and that belongs into a seperate loop.

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

  23. #173
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    I assumed my problem was that i wasnt identifying the defender as much as the attcker so I did this:

    Code:
    STDEHANDLER(BattleAftermathRegardEvent)
    {
    	Army army;
    	Army darmy; //added by E to check defender army
    	MapPoint pos;
    	MapPoint dpos; //added by E to check defender army
    	Unit ta;
    	Unit td;
    	sint32 attack_owner, defense_owner;
    
    	
    	args->GetArmy(0, army);
    
    	args->GetArmy(1, darmy);  //added by E to check defender army
    
    	if(!args->GetPos(0, pos))
    		return GEV_HD_Continue;
    
    	if(!args->GetPos(1, dpos))
    	return GEV_HD_Continue;
    
    	args->GetUnit(0, ta);
    	args->GetUnit(1, td);
    
    	if(!args->GetPlayer(0, attack_owner))
    		return GEV_HD_Continue;
    
    	if(!args->GetPlayer(1, defense_owner))
    		return GEV_HD_Continue;
    
    
    	bool AllSneakAttack = true;
    
    	sint32 i;
    	if(army.IsValid()) {
    		for(i = 0; i < army.Num(); i++) {
    			if(!army[i].GetDBRec()->GetSneakAttack() && !darmy[i].GetDBRec()->GetSneakAttack()){
    				AllSneakAttack = false;
    				break;
    			}	
    		}
    	}
    
    	if(!AllSneakAttack){
    		Diplomat & defending_diplomat = Diplomat::GetDiplomat(defense_owner);
    		defending_diplomat.LogViolationEvent(attack_owner, PROPOSAL_TREATY_CEASEFIRE);
    	}
    
    	return GEV_HD_Continue;
    }
    but still its the same problem, it just bypasses the !sneakattack. and chaning the bool to = false switches it the other way so it seems something is preventing it from switching the bool.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  24. #174
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,254
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    September 19, 2014
    Local Time
    04:47

    Post

    Originally posted by E
    Code:
    	args->GetArmy(1, darmy);  //added by E to check defender army
    E, I already told you that this doesn't work, the BattleAftermath event does not have to army arguments only one army is passed. And actually it surprises me that the game doesn't crash.

    You have to check the defender units at the given position, well given if they are still there. And another possibility is that it might be at other places. Actually you have to do this if you want apply the new feature to slavers.

    But again you have to check the location of the battle whether there are units with hiiden nationality, if there are all units with hidden nationality then you are happy otherwise you aren't. And in the worst case you ave to deal with 12 armies there, each with one single unit.

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

  25. #175
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    darn and I thought this would be an easy fix... since i dont have access to my code right now in psuedo would it be somethinglike:

    mappoint battlepos

    get cell->battlepos
    get (m_all_units)
    unit.dbrec->sneakattack


    basically using something from player.cpp where they get a position then check all units there. Also should this be a check before i do a return on a bool? I'm assuming yes.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  26. #176
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,254
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    September 19, 2014
    Local Time
    04:47

    Post

    Actually it is rather something like this:

    Code:
    get cell unit list from pos // you have pos and this should be the battle pos
    for all units from cell unit list do
        if unit is not sneak attack do
            AllSneakAttack set to false
            break
        end if
    end for
    This piece of code goes directly into gap between the army sneak attack loop and the threaty cease fire violation code. The sneak attack setter is used from the code before.

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

  27. #177
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    Martin I gave it a shot, the code atleast works for theattacker and it triggers a war execpt it doesnt check the SneakAttack. In bold is the code i settled on. but with the '//' proceeding it is the notes I took (you asked for me to keep them in before). I took them mainly from armydata when i did a search on cellunit list. Am I on the right track? Why is it not seeing the sneak attack flag on the defender?


    Code:
    STDEHANDLER(BattleAftermathRegardEvent)
    {
    	Army army;
    //	Army darmy; //added by E to check defender army
    	MapPoint pos;
    //	MapPoint dpos; //added by E to check defender army
    	Unit ta;
    	Unit td;
    	sint32 attack_owner, defense_owner;
    
    	
    	args->GetArmy(0, army);
    
    //	args->GetArmy(1, darmy);  //added by E to check defender army
    
    	if(!args->GetPos(0, pos))
    		return GEV_HD_Continue;
    
    //	if(!args->GetPos(1, dpos)) //added by E
    //	return GEV_HD_Continue;
    
    	args->GetUnit(0, ta);
    	args->GetUnit(1, td);
    
    	if(!args->GetPlayer(0, attack_owner))
    		return GEV_HD_Continue;
    
    	if(!args->GetPlayer(1, defense_owner))
    		return GEV_HD_Continue;
    
    
    	bool AllSneakAttack = true;
    
    	sint32 i;
    	if(army.IsValid()) {
    		for(i = 0; i < army.Num(); i++) {
    			if(!army[i].GetDBRec()->GetSneakAttack()){
    				AllSneakAttack = false;
    				break;
    			}	
    		}
    	}
    
    //	CellUnitList candidate_units;
    //	g_theWorld->GetArmy(army->RetPos(), candidate_units);
    //	for (sint32 j = 0; j < candidate_units.Num(); j++)
    //		{
    //			tmp_army = candidate_units[j].GetArmy();
    //			Assert( g_theArmyPool->IsValid(tmp_army) );
    
    
    //	get cell unit list from pos // you have pos and this should be the battle pos
    //		for all units from cell unit list do
    //			if unit is not sneak attack do
    
    
    //	CellUnitList defender;
    //	for(i = 0; i < cell->GetNumUnits(); i++) {
    //		if(!cell->AccessUnit(i).GetDBRec()->GetSneakAttack()) {
    //		if(!ul->Access(i).GetArmy().IsValid()) {
    
    	
    //	CellUnitList defender;
    //	g_theWorld->GetArmy(pos, defender);
    
      //  for(i = 0; i < cell->GetNumUnits(); i++) { 
    		
    //        if (!cell->AccessUnit(i).GetDBRec()->GetSneakAttack()) 
    
    	Cell *cell = g_theWorld->GetCell(pos);
    	CellUnitList *defender = g_theWorld->GetCell(pos)->UnitArmy();
    	for(i = 0; i < defender->Num(); i++) {
    		if(!defender->Access(i).GetDBRec()->GetSneakAttack()){
    			AllSneakAttack = false;
    			break;
    		}
    	}
    
    
    	if(!AllSneakAttack){
    
    		Diplomat & defending_diplomat = Diplomat::GetDiplomat(defense_owner);
    		defending_diplomat.LogViolationEvent(attack_owner, PROPOSAL_TREATY_CEASEFIRE);
    	}
    
    	return GEV_HD_Continue;
    }
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  28. #178
    Martin Gühmann
    Administrator Martin Gühmann's Avatar
    Join Date
    02 Mar 2001
    Location
    Tübingen, Germany
    Posts
    7,254
    Country
    This is Martin Gühmann's Country Flag
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Local Date
    September 19, 2014
    Local Time
    04:47

    Post

    Originally posted by E
    Martin I gave it a shot, the code atleast works for theattacker and it triggers a war execpt it doesnt check the SneakAttack. In bold is the code i settled on. but with the '//' proceeding it is the notes I took (you asked for me to keep them in before). I took them mainly from armydata when i did a search on cellunit list. Am I on the right track? Why is it not seeing the sneak attack flag on the defender?
    Well maybe you would like now to look unto the code while the program is executed. You can't really be sure if the defenders are still there if the battle is over, or if they are killed during the battle or somethingt else. however from a glance at the code it looked like the defenders would be still there when this event is executed.

    So now it is time to test the debuger. I hope you got the executable working from its creation directory otherwise make it work from there. To use the debugger on the executable you just have to press in MSVS F5. But before you press F5 you should set some break points so that the debugger knows when you want to inspect the code.

    To do this right click on the edge of the code window in MSVS and a pop up menu appears that's allows you to set a break point and to remove it and to deactivate it, etc..

    But before you start the program with the debugger you have to do one another thing the executable has to be started with the nonexclusive argument, so that you can reach the debugger when the debugger halts the program. Otherwise you can only kill the program in order to reach the debugger.

    There is a certain place in MSVC where you can enter the command line arguments, unfortunately I forgot the place and I don't have MSVS6 here.

    But that are some questions you have to ask yourself, is the working hypothesis correct and of course how to figure out whether it is correct. And of course not always is the debugger the right tool. Other tools are printf statements or simply reading the code.

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

  29. #179
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    Thanks Martin,
    I havent gotten around to this yet because I'm just about willing to settle on it being an attacker only thing.

    but when I thought about that I think I realized tht the event i was playing with only logs an attacker's event, where as the killunit event (where civilian regard cost is found) tracks what happens to defenders

    There might be a way to mix those two codes but I'm not sure the other option was to add a sneak attack event into the kill unit event but then i get into a similar situation but from the dfender viewpoint. So a check on the defender will determine if war is declared.

    so i get stuck where if the defender is not sneak attack but the attacker is then war is still declared. not sure how to fix that.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  30. #180
    Ekmek
    Emperor Ekmek's Avatar
    Join Date
    26 May 1999
    Posts
    3,156
    Country
    This is Ekmek's Country Flag
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Local Date
    September 18, 2014
    Local Time
    19:47
    Martin,
    I did try adding breaks and a PRINT statement andd they didnot show in the log but it kept going to armydata and i found this which might be why its only looking at the attack, but looking at how the event is called I don't think I should add a sneakattack here instead of the regard file I've been messing with. Or am i wrong?

    Code:
    sint32 ArmyData::Fight(CellUnitList &defender)
    
    ...SOMECODE...
    
    	if(defenderSucks) {
    		
    		if(ta.IsValid()) {
    			g_director->AddAttack(ta, td);
    			g_gevManager->AddEvent(GEV_INSERT_AfterCurrent,
    								   GEV_BattleAftermath,
    								   GEA_Army, m_id,
    								   GEA_MapPoint, pos,
    								   GEA_Unit, ta,
    								   GEA_Unit, td,
    								   GEA_Player, m_owner,
    								   GEA_Player, defense_owner,
    								   GEA_Int, 0, 
    								   GEA_End);
    			for(i = 0; i < defender.Num(); i++) {				
    				CAUSE_REMOVE_ARMY cause = CAUSE_REMOVE_ARMY_DIED_IN_ATTACK;
    				if(defender[i ].m_id == td.m_id) {					
    					cause  = CAUSE_REMOVE_ARMY_DIED_IN_ATTACK_ON_TOP;
    				}
    				g_gevManager->AddEvent(GEV_INSERT_AfterCurrent,
    									   GEV_KillUnit,
    									   GEA_Unit, defender[i ].m_id,
    									   GEA_Int, cause,
    									   GEA_Player, m_owner,
    									   GEA_End);
    			}
    		}
    ...SOMECODE...
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

Page 6 of 10 FirstFirst ... 3 4 5 6 7 8 9 ... LastLast

Similar Threads

  1. CTP Source Code
    By DCMike in forum Call to Power 2
    Replies: 2
    Last Post: August 12, 2009, 14:28
  2. Civ ii source code
    By McMonkey in forum Civilization I and Civilization II
    Replies: 25
    Last Post: March 8, 2009, 19:05
  3. Who has the source code?
    By The_Reckoning in forum Alpha Centauri
    Replies: 3
    Last Post: March 1, 2009, 12:47
  4. Civ 2 source code
    By McMonkey in forum Civilization I and Civilization II
    Replies: 2
    Last Post: January 11, 2009, 11:15
  5. Javadoc Documentation for current source / + current source code
    By Mark_Everson in forum Clash of Civilizations
    Replies: 0
    Last Post: September 17, 2000, 14:15

Bookmarks

Posting Permissions