diff --git a/include/core.h b/include/core.h index c475c13..7b07fc5 100644 --- a/include/core.h +++ b/include/core.h @@ -1503,7 +1503,6 @@ public: }; #include -#include // expose bot super-globals extern NetworkMsg netmsg; @@ -1511,7 +1510,6 @@ extern Localizer locale; extern Waypoint waypoints; extern BotManager bots; extern Engine engine; -extern Game game; // prototypes of bot functions... extern int GetWeaponReturn (bool isString, const char *weaponAlias, int weaponIndex = -1); diff --git a/include/gamestate.h b/include/gamestate.h index f576c96..ae0e30b 100644 --- a/include/gamestate.h +++ b/include/gamestate.h @@ -11,7 +11,31 @@ #pragma once -// +// netmessage handler class +class NetworkMsg +{ +private: + Bot *m_bot; + int m_state; + int m_message; + int m_registerdMessages[NETMSG_NUM]; + +public: + NetworkMsg (void); + ~NetworkMsg (void) { }; + + void Execute (void *p); + inline void Reset (void) { m_message = NETMSG_UNDEFINED; m_state = 0; m_bot = NULL; }; + void HandleMessageIfRequired (int messageType, int requiredType); + + inline void SetMessage (int message) { m_message = message; } + inline void SetBot (Bot *bot) { m_bot = bot; } + + inline int GetId (int messageType) { return m_registerdMessages[messageType]; } + inline void SetId (int messageType, int messsageIdentifier) { m_registerdMessages[messageType] = messsageIdentifier; } +}; + +// game events class IGameEvents { public: diff --git a/project/yapb.vcxproj b/project/yapb.vcxproj index 01f8564..bcd4232 100644 --- a/project/yapb.vcxproj +++ b/project/yapb.vcxproj @@ -27,7 +27,6 @@ - @@ -36,13 +35,12 @@ - + - diff --git a/project/yapb.vcxproj.filters b/project/yapb.vcxproj.filters index 7ac61fb..542501b 100644 --- a/project/yapb.vcxproj.filters +++ b/project/yapb.vcxproj.filters @@ -72,9 +72,6 @@ include - - include - @@ -89,9 +86,6 @@ source - - source - source @@ -110,7 +104,7 @@ source - + source diff --git a/source/gamestate.cpp b/source/gamestate.cpp deleted file mode 100644 index c49297d..0000000 --- a/source/gamestate.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// -// Yet Another POD-Bot, based on PODBot by Markus Klinge ("CountFloyd"). -// Copyright (c) YaPB Development Team. -// -// This software is licensed under the BSD-style license. -// Additional exceptions apply. For full license details, see LICENSE.txt or visit: -// http://yapb.jeefo.net/license -// - -#include \ No newline at end of file diff --git a/source/globals.cpp b/source/globals.cpp index 43efdc2..5536c4a 100644 --- a/source/globals.cpp +++ b/source/globals.cpp @@ -15,7 +15,6 @@ Localizer locale; Waypoint waypoints; BotManager bots; Engine engine; -Game game; bool g_canSayBombPlanted = true; bool g_isMetamod = false; diff --git a/source/interface.cpp b/source/interface.cpp index dbe3ffa..76dc80b 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -457,14 +457,6 @@ void CommandHandler (void) engine.Printf ("Unknown command: %s", CMD_ARGV (1)); } -class GameEvents : public IGameEvents -{ - virtual void OnNewRound (void) - { - RoundInit (); - } -} g_botEventListener; - void ParseVoiceEvent (const String &base, int type, float timeToRepeat) { // this function does common work of parsing single line of voice chatter @@ -926,9 +918,6 @@ void GameDLLInit (void) // server is enabled. Here is a good place to do our own game session initialization, and // to register by the engine side the server commands we need to administrate our bots. - // register bot event listner - game.RegisterEventListener (&g_botEventListener); - DetectCSVersion (); { // print game detection info @@ -1025,7 +1014,7 @@ int Spawn (edict_t *ent) PRECACHE_SOUND (ENGINE_STR ("common/wpn_moveselect.wav")); // path add/delete cancel PRECACHE_SOUND (ENGINE_STR ("common/wpn_denyselect.wav")); // path add/delete error - events->OnNewRound (); + RoundInit (); g_mapType = NULL; // reset map type as worldspawn is the first entity spawned // detect official csbots here, as they causing crash in linkent code when active for some reason @@ -2344,7 +2333,7 @@ edict_t *pfnFindEntityByString (edict_t *edictStartSearchAfter, const char *fiel { // round starts in counter-strike 1.5 if (strcmp (value, "info_map_parameters") == 0) - events->OnNewRound (); + RoundInit (); if (g_isMetamod) RETURN_META_VALUE (MRES_IGNORED, 0); @@ -2947,39 +2936,9 @@ export int Meta_Query (char *ifvers, plugin_info_t **pPlugInfo, mutil_funcs_t *p // is for metamod to retrieve basic information about the plugin, such as its meta-interface // version, for ensuring compatibility with the current version of the running metamod. - // keep track of the pointers to metamod function tables metamod gives us gpMetaUtilFuncs = pMetaUtilFuncs; *pPlugInfo = &Plugin_info; - // check for interface version compatibility - if (strcmp (ifvers, Plugin_info.ifvers) != 0) - { - int metaMajor = 0, metaMinor = 0, pluginMajor = 0, pluginMinor = 0; - - LOG_CONSOLE (PLID, "%s: meta-interface version mismatch (metamod: %s, %s: %s)", Plugin_info.name, ifvers, Plugin_info.name, Plugin_info.ifvers); - LOG_MESSAGE (PLID, "%s: meta-interface version mismatch (metamod: %s, %s: %s)", Plugin_info.name, ifvers, Plugin_info.name, Plugin_info.ifvers); - - // if plugin has later interface version, it's incompatible (update metamod) - sscanf (ifvers, "%d:%d", &metaMajor, &metaMinor); - sscanf (META_INTERFACE_VERSION, "%d:%d", &pluginMajor, &pluginMinor); - - if (pluginMajor > metaMajor || (pluginMajor == metaMajor && pluginMinor > metaMinor)) - { - LOG_CONSOLE (PLID, "metamod version is too old for this plugin; update metamod"); - LOG_MMERROR (PLID, "metamod version is too old for this plugin; update metamod"); - - return FALSE; - } - - // if plugin has older major interface version, it's incompatible (update plugin) - else if (pluginMajor < metaMajor) - { - LOG_CONSOLE (PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin"); - LOG_MMERROR (PLID, "metamod version is incompatible with this plugin; please find a newer version of this plugin"); - - return FALSE; - } - } return TRUE; // tell metamod this plugin looks safe } @@ -2989,15 +2948,6 @@ export int Meta_Attach (PLUG_LOADTIME now, metamod_funcs_t *functionTable, meta_ // where we can tell if the plugin will be allowed to run or not, we wait until here to make // our initialization stuff, like registering CVARs and dedicated server commands. - // are we allowed to load this plugin now ? - if (now > Plugin_info.loadable) - { - LOG_CONSOLE (PLID, "%s: plugin NOT attaching (can't load plugin right now)", Plugin_info.name); - LOG_MMERROR (PLID, "%s: plugin NOT attaching (can't load plugin right now)", Plugin_info.name); - - return FALSE; // returning false prevents metamod from attaching this plugin - } - // keep track of the pointers to engine function tables metamod gives us gpMetaGlobals = pMGlobals; memcpy (functionTable, &gMetaFunctionTable, sizeof (metamod_funcs_t)); diff --git a/source/netmsg.cpp b/source/netmsg.cpp index 0692756..201d0b4 100644 --- a/source/netmsg.cpp +++ b/source/netmsg.cpp @@ -11,12 +11,12 @@ NetworkMsg::NetworkMsg (void) { - m_message = NETMSG_UNDEFINED; - m_state = 0; - m_bot = NULL; + m_message = NETMSG_UNDEFINED; + m_state = 0; + m_bot = NULL; - for (int i = 0; i < NETMSG_NUM; i++) - m_registerdMessages[i] = -1; + for (int i = 0; i < NETMSG_NUM; i++) + m_registerdMessages[i] = -1; } void NetworkMsg::HandleMessageIfRequired (int messageType, int requiredType) @@ -30,7 +30,7 @@ void NetworkMsg::Execute (void *p) if (m_message == NETMSG_UNDEFINED) return; // no message or not for bot, return - // some needed variables + // some needed variables static byte r, g, b; static byte enabled; @@ -430,7 +430,7 @@ void NetworkMsg::Execute (void *p) g_bombPlanted = g_bombSayString = true; g_timeBombPlanted = engine.Time (); - + for (int i = 0; i < engine.MaxClients (); i++) { Bot *bot = bots.GetBot (i);