From 8272138c2c54e12ef3cbc72184e3d7ba513fc4b0 Mon Sep 17 00:00:00 2001 From: driAn Date: Sat, 25 Nov 2006 14:33:00 +0000 Subject: [PATCH] invalid free fixed git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@725 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/bot/botmanager.cpp | 6 +++--- source/src/client.cpp | 2 ++ source/src/clientgame.cpp | 9 ++++----- source/src/weapon.cpp | 15 +-------------- 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/source/src/bot/botmanager.cpp b/source/src/bot/botmanager.cpp index 6c3dc9cf..df674c06 100644 --- a/source/src/bot/botmanager.cpp +++ b/source/src/bot/botmanager.cpp @@ -325,7 +325,7 @@ void CBotManager::EndMap() // Remove all bots loopv(bots) { - if (!bots[i]) + if(!bots[i] || !bots[i]->pBot) continue; // Store bots so they can be re-added after map change @@ -907,7 +907,7 @@ botent *CBotManager::CreateBot(const char *team, const char *skill, const char * #if defined VANILLA_CUBE m->pBot = new CCubeBot; #elif defined AC_CUBE - m->pBot = new CACBot; + m->pBot = new CACBot; #else #error "Unsupported mod!" #endif @@ -1086,7 +1086,7 @@ void kickallbots(void) delete bots[i]->pBot; freebotent(bots[i]); } - } + }; bots.setsize(0); } diff --git a/source/src/client.cpp b/source/src/client.cpp index eedf5cab..48b8f149 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -1,6 +1,7 @@ // client.cpp, mostly network related client game code #include "cube.h" +#include "bot/bot.h" ENetHost *clienthost = NULL; int connecting = 0; @@ -151,6 +152,7 @@ void disconnect(int onlyclean, int async) clientnum = -1; c2sinit = false; player1->lifesequence = 0; + if(m_botmode) BotManager.EndMap(); loopv(players) zapplayer(players[i]); localdisconnect(); diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 8520b89f..b99242f6 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -231,11 +231,10 @@ void updateworld(int curtime, int lastmillis) // main game update loop { loopv(sleeps) { - scriptsleep &s = sleeps[i]; - if(s.wait && lastmillis > s.wait) - { - execute(s.cmd); - delete[] s.cmd; + if(sleeps[i].wait && lastmillis > sleeps[i].wait) + { + execute(sleeps[i].cmd); + delete[] sleeps[i].cmd; sleeps.remove(i--); }; }; diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 712cd55c..81b465cf 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -9,25 +9,12 @@ const int SGRAYS = 21; //down from 21, must be 32 or less (default) const float SGSPREAD = 2; vec sg[SGRAYS]; -//change the particales -/*guninfo guns[NUMGUNS] = -{ - { S_KNIFE, S_NULL, 0, 500, 50, 0, 0, 1, 1, 1, 0, 0, false, "knife" }, - { S_PISTOL, S_RPISTOL, 1400, 170, 20, 0, 0, 80, 10, 8, 6, 5, false, "pistol" }, // *SGRAYS - { S_SHOTGUN, S_RSHOTGUN, 2400, 1000, 6, 0, 0, 1, 35, 7, 9, 9, false, "shotgun" }, //reload time is for 1 shell from 7 too powerful to 6 - { S_SUBGUN, S_RSUBGUN, 1650, 80, 17, 0, 0, 70, 15, 30, 1, 2, true, "subgun" }, - { S_SNIPER, S_RSNIPER, 1950, 1500, 72, 0, 0, 60, 50, 5, 4, 4, false, "sniper" }, - { S_ASSAULT, S_RASSAULT, 2000, 130, 25, 0, 0, 20, 40, 20, 0, 2, true, "assault" }, //recoil was 44 - { S_NULL, S_NULL, 1000, 1200, 150, 20, 6, 1, 1, 1, 3, 1, "grenade" }, -};*/ - -// fixme: tmp gun test guninfo guns[NUMGUNS] = { { S_KNIFE, S_NULL, 0, 500, 50, 0, 0, 1, 1, 1, 0, 0, false, "knife" }, { S_PISTOL, S_RPISTOL, 1400, 170, 19, 0, 0, 80, 10, 8, 6, 5, false, "pistol" }, // *SGRAYS { S_SHOTGUN, S_RSHOTGUN, 2400, 1000, 5, 0, 0, 1, 35, 7, 9, 9, false, "shotgun" }, //reload time is for 1 shell from 7 too powerful to 6 - { S_SUBGUN, S_RSUBGUN, 1650, 80, 15, 0, 0, 70, 15, 30, 1, 2, true, "subgun" }, + { S_SUBGUN, S_RSUBGUN, 1650, 80, 16/*15*/,0, 0, 70, 15, 30, 1, 2, true, "subgun" }, { S_SNIPER, S_RSNIPER, 1950, 1500, 85, 0, 0, 60, 50, 5, 4, 4, false, "sniper" }, { S_ASSAULT, S_RASSAULT, 2000, 130, 25, 0, 0, 20, 40, 20, 0, 2, true, "assault" }, //recoil was 44 { S_NULL, S_NULL, 1000, 1200, 150, 20, 6, 1, 1, 1, 3, 1, "grenade" },