HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

player leave code

08-30-2005, 03:44 AM#1
drdlord
This used to work but once I started adding anti-leak code it doesn't...

Trigger: Player 1
Events
Time - Every 5.00 seconds of game time
Conditions
(Player 1 (Red) slot status) Equal to Has left the game
Defeat Equal to False
Actions
Trigger - Turn off (This trigger)
Game - Display to (All players) for 15.00 seconds the text: ((Name of Player 1 (Red)) + |c0000cdf9 has left the game|r)
Player Group - Remove Player 1 (Red) from Force1
Player Group - Remove Player 11 (Dark Green) from Force1
Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 1 (Red)) and do (Unit - Change ownership of (Picked unit) to (Random player from Force1) and Change color)
Player Group - Add Player 11 (Dark Green) to Force1


in my current map the game tells everyone that a player left, but it doesn't give their towers away anymore... is there a bug in this code or it is posible that that another trigger is messing with this one somehow?

Map is availible here: http://www.wc3sear.ch/?p=Maps&ID=4307
08-30-2005, 08:55 AM#2
Anitarf
You said you started adding anti-leak code when this stopped working? Like, anti memory leak? Did you by any chance destroy the Force1 anywhere? I'm just guessing this could be your problem. You shouldn't destroy objects that you still use, you should only remove those that are created temporarily and you only need them once.
08-30-2005, 06:59 PM#3
drdlord
I only destroy my temporary groups, but I do set a temporary = force1 then destroy the temp, does this destroy the force1 aswell?
08-30-2005, 08:58 PM#4
Anitarf
Quote:
Originally Posted by drdlord
I only destroy my temporary groups, but I do set a temporary = force1 then destroy the temp, does this destroy the force1 aswell?
Yes it does. Remember, object variables are just pointers that point to the object. (as opposed to integer, real, boolean... variables which hold their value directly in themselves) When you destroy a variable, you don't actually destroy it but the object it points to.
08-31-2005, 05:09 AM#5
drdlord
ah, MUCH easier to understand in C, if I use new I have to use delete. or in java, just ignore them. not worrying about did I create somthing with this line or does it jsut copy somthing else... now to find the line that removes a pointer to force1's handel...
08-31-2005, 04:38 PM#6
drdlord
Umm... problem, I don't destroy anything that points to force1's handel yet it still doesn't always work, it works for the leavers at the begining, but if someone plays for a while then leaves their towers/shrines arn't divided

can someone please look at my map and tell me what I messed up?

get map here
09-08-2005, 04:15 AM#7
PCPharaoh
You might want to make the event: Player - Player leaves the game instead of a check every 5 seconds. It might save the map from a tiny bit of lag.