diff --git a/source/src/bot/ac_bot.cpp b/source/src/bot/ac_bot.cpp index 3ccf17f6..3fd47cc1 100644 --- a/source/src/bot/ac_bot.cpp +++ b/source/src/bot/ac_bot.cpp @@ -10,7 +10,7 @@ // // -#include "../cube.h" +#include "bot.h" #ifdef AC_CUBE diff --git a/source/src/bot/ac_bot_ai.cpp b/source/src/bot/ac_bot_ai.cpp index a339ee75..9345e9bb 100644 --- a/source/src/bot/ac_bot_ai.cpp +++ b/source/src/bot/ac_bot_ai.cpp @@ -9,7 +9,7 @@ -#include "../cube.h" +#include "bot.h" #ifdef AC_CUBE diff --git a/source/src/bot/bot.cpp b/source/src/bot/bot.cpp index 80c26623..f00a1c50 100644 --- a/source/src/bot/bot.cpp +++ b/source/src/bot/bot.cpp @@ -10,7 +10,7 @@ // // -#include "../cube.h" +#include "bot.h" vector bots; diff --git a/source/src/bot/bot.h b/source/src/bot/bot.h index 80d7c9ae..312049f4 100644 --- a/source/src/bot/bot.h +++ b/source/src/bot/bot.h @@ -42,6 +42,7 @@ #ifndef BOT_H #define BOT_H +#include "../cube.h" //#define RELEASE_BUILD // Set when you want to make a release build diff --git a/source/src/bot/bot_ai.cpp b/source/src/bot/bot_ai.cpp index 4704e412..fadbf371 100644 --- a/source/src/bot/bot_ai.cpp +++ b/source/src/bot/bot_ai.cpp @@ -10,7 +10,7 @@ // Code of CBot - Start -#include "../cube.h" +#include "bot.h" extern vector sents; extern vector monsters; diff --git a/source/src/bot/bot_util.cpp b/source/src/bot/bot_util.cpp index de4da049..7f15a115 100644 --- a/source/src/bot/bot_util.cpp +++ b/source/src/bot/bot_util.cpp @@ -10,7 +10,7 @@ // // -#include "../cube.h" +#include "bot.h" // Function code by PMB - Begin diff --git a/source/src/bot/bot_waypoint.cpp b/source/src/bot/bot_waypoint.cpp index 577b690e..ff0251f6 100644 --- a/source/src/bot/bot_waypoint.cpp +++ b/source/src/bot/bot_waypoint.cpp @@ -7,7 +7,7 @@ // Author: Rick // -#include "../cube.h" +#include "bot.h" vec v_debuggoal = g_vecZero; @@ -758,7 +758,6 @@ void CWaypointClass::DrawNearWaypoints() } } - extern bool intermission; if (intermission) return; /*for(int i=0;ipBot && bots[i]->name[0] && bots[i]->team[0]) { - if (bots[i]->pBot && bots[i]->name[0] && bots[i]->team[0]) - { - CStoredBot *pStoredBot = new CStoredBot(bots[i]->name, bots[i]->team, - bots[i]->pBot->m_sSkillNr); - m_StoredBots.AddNode(pStoredBot); - } - delete bots[i]->pBot; - } + CStoredBot *pStoredBot = new CStoredBot(bots[i]->name, bots[i]->team, + bots[i]->pBot->m_sSkillNr); + m_StoredBots.AddNode(pStoredBot); + }; + delete bots[i]->pBot; bots[i]->pBot = NULL; freebotent(bots[i]); - } + }; bots.setsize(0); condebug("Cleared all bots"); m_fReAddBotDelay = lastmillis + 7500; @@ -364,8 +350,6 @@ void CBotManager::BeginMap(char *szMapName) { EndMap(); // End previous map - if (!ishost()) return; - WaypointClass.Init(); WaypointClass.SetMapName(szMapName); if (!WaypointClass.LoadWaypoints()) @@ -863,8 +847,6 @@ void CBotManager::CalculateMaxAStarCount() void CBotManager::PickNextTrigger() { - if (!ishost()) return; - short lowest = -1; bool found0 = false; // True if found a trigger with nr 0 @@ -990,18 +972,15 @@ bool botmode() void addbot(char *arg1, char *arg2, char *arg3) { if(!botmode()) return; - if (ishost()) - { - conoutf("Creating bot...\n"); - botent *b = BotManager.CreateBot(arg1, arg2, arg3); - if (b) - conoutf("connected: %s", b->name); - else - { - conoutf("Error: Couldn't create bot!"); - return; - } - } + conoutf("Creating bot...\n"); + botent *b = BotManager.CreateBot(arg1, arg2, arg3); + if (b) + conoutf("connected: %s", b->name); + else + { + conoutf("Error: Couldn't create bot!"); + return; + } } COMMAND(addbot, ARG_3STR); @@ -1013,13 +992,10 @@ void addnbot(char *arg1, char *arg2, char *arg3) int i = atoi(arg1); - if (ishost()) + while(i > 0) { - while(i > 0) - { - addbot(arg2, arg3, NULL); - i--; - } + addbot(arg2, arg3, NULL); + i--; } } @@ -1027,7 +1003,6 @@ COMMAND(addnbot, ARG_3STR); void botsshoot(int Shoot) { - if (!ishost()) return; if (Shoot) { BotManager.SetBotsShoot(true); @@ -1044,7 +1019,6 @@ COMMAND(botsshoot, ARG_1INT); void idlebots(int Idle) { - if (!ishost()) return; if (Idle) { BotManager.SetIdleBots(true); @@ -1091,14 +1065,11 @@ void kickbot(const char *szName) if (iBotInd != -1) { - if (ishost()) - { - botent *d = bots[iBotInd]; - if(d->name[0]) conoutf("bot %s disconnected", d->name); - delete d->pBot; - bots.remove(iBotInd); - freebotent(d); - } + botent *d = bots[iBotInd]; + if(d->name[0]) conoutf("bot %s disconnected", d->name); + delete d->pBot; + bots.remove(iBotInd); + freebotent(d); } } @@ -1110,12 +1081,9 @@ void kickallbots(void) { if (bots[i]) { - if (ishost()) - { - if(bots[i]->name[0]) conoutf("bot %s disconnected", bots[i]->name); - delete bots[i]->pBot; - freebotent(bots[i]); - } + if(bots[i]->name[0]) conoutf("bot %s disconnected", bots[i]->name); + delete bots[i]->pBot; + freebotent(bots[i]); } } @@ -1180,22 +1148,19 @@ void botskill(char *bot, char *skill) return; } - if (ishost()) - { - if (bot) - { - loopv(bots) - { - if (bots[i] && !strcmp(bots[i]->name, bot)) - { - BotManager.ChangeBotSkill(SkillNr, bots[i]); - break; - } - } - } - else - BotManager.ChangeBotSkill(SkillNr); - } + if (bot) + { + loopv(bots) + { + if (bots[i] && !strcmp(bots[i]->name, bot)) + { + BotManager.ChangeBotSkill(SkillNr, bots[i]); + break; + } + } + } + else + BotManager.ChangeBotSkill(SkillNr); } COMMAND(botskill, ARG_2STR); diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index a09dd34e..a601a237 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -1,6 +1,8 @@ // clientgame.cpp: core game related stuff #include "cube.h" +#include "bot/bot.h" + int nextmode = 0; // nextmode becomes gamemode after next map load VAR(gamemode, 1, 0, 0); @@ -8,8 +10,7 @@ flaginfo flaginfos[2]; void mode(int n) { - if((n>=7 && n<=8) && clienthost) conoutf("this mode is for singleplayer only"); - else addmsg(SV_GAMEMODE, "ri", nextmode = n); + if(!m_botmode || !multiplayer()) addmsg(SV_GAMEMODE, "ri", nextmode = n); }; COMMAND(mode, ARG_1INT); @@ -145,7 +146,7 @@ void arenarespawn() conoutf("new round starting... fight!"); respawnself(); // Added by Rick: Let all bots respawn if were the host - if (ishost()) BotManager.RespawnBots(); + if (m_botmode) BotManager.RespawnBots(); //End add by Rick clearbounceents(); }; @@ -255,7 +256,7 @@ void updateworld(int curtime, int lastmillis) // main game update loop //monsterthink(); // Added by Rick: let bots think - BotManager.Think(); + if(m_botmode) BotManager.Think(); //put game mode extra call here if(player1->state==CS_DEAD) diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 2cd454b3..7ccefd06 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -167,11 +167,6 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) c2sinit = false; // send new players my info again conoutf("connected: %s", &text); gun_changed = true; - // Added by Rick: If we are the host("the bot owner"), tell the bots - // to update their stats - if (ishost()) - BotManager.LetBotsUpdateStats(); - // End add by Rick }; s_strncpy(d->name, text, MAXNAMELEN+1); getstring(text, p); diff --git a/source/src/cube.h b/source/src/cube.h index b3a3acc5..1c5bcdb8 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -1,3 +1,6 @@ +#ifndef __CUBE_H__ +#define __CUBE_H__ + /// one big bad include file for the whole engine... nasty! #ifdef __GNUC__ @@ -109,25 +112,14 @@ extern int curtime; // current frame time extern int gamemode, nextmode; extern int xtraverts; extern bool demoplayback; +extern bool intermission; #define VIRTW 2400 // virtual screen size for text & HUD #define VIRTH 1800 #define FONTH 64 #define PIXELTAB (VIRTW/12) -// Added by Rick -extern ENetHost *clienthost; -inline bool ishost(void) { return !clienthost; }; - -void splaysound(int n, vec *loc=0); -void addteamscore(playerent *d); -void renderscore(playerent *d); -extern void conoutf(const char *s, ...); // Moved from protos.h -extern void particle_trail(int type, int fade, vec &from, vec &to); // Moved from protos.h -extern bool listenserv; -extern bool intermission; -#include "bot/bot.h" -// End add by Rick - #include "protos.h" // external function decls +#endif + diff --git a/source/src/protos.h b/source/src/protos.h index 8774a1cf..d914a70b 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -23,6 +23,7 @@ extern void renderconsole(); extern char *getcurcommand(); extern char *addreleaseaction(char *s); extern void writebinds(FILE *f); +extern void conoutf(const char *s, ...); // menus extern bool rendermenu(); @@ -194,8 +195,7 @@ extern void loadingscreen(); // renderparticles extern void particle_splash(int type, int num, int fade, vec &p); -//extern void particle_splash(int num, int fade, vec &p); -// extern void particle_trail(int type, int fade, vec &from, vec &to); Moved to cube.h by Rick +extern void particle_trail(int type, int fade, vec &from, vec &to); extern void render_particles(int time); // worldio diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 58aafa41..7e222ec7 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -1,6 +1,7 @@ // rendergl.cpp: core opengl rendering stuff #include "cube.h" +#include "bot/bot.h" #ifdef __APPLE__ #define GL_COMBINE_EXT GL_COMBINE_ARB diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index c2d0149a..3fe7e901 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -1,6 +1,7 @@ // weapon.cpp: all shooting and effects code #include "cube.h" +#include "bot/bot.h" struct guninfo { short sound, reload, reloadtime, attackdelay, damage, projspeed, part, spread, recoil, magsize, mdl_kick_rot, mdl_kick_back; bool isauto; char *name; }; diff --git a/source/src/world.cpp b/source/src/world.cpp index 78ea3193..d09781e2 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -1,6 +1,7 @@ // world.cpp: core map management stuff #include "cube.h" +#include "bot/bot.h" extern char *entnames[]; // lookup from map entities above to strings @@ -44,7 +45,7 @@ void settagareas() // set for playing { settag(0, 1); loopv(ents) if(ents[i].type==CARROT) setspawn(i, true); - if(ishost()) BotManager.PickNextTrigger(); + if(m_botmode) BotManager.PickNextTrigger(); }; // End mod