fixed 'remove bot menu' not showing up

rewritten posix makefile from the ground
reworked menu logic, so endpoint menu item will redraw menu once again, instead of closing it.
This commit is contained in:
jeefo 2016-09-22 15:47:35 +03:00
commit 75d1f1ec58
7 changed files with 251 additions and 197 deletions

View file

@ -22,7 +22,7 @@ before_script:
- export PATH=$PATH:/tmp/osxcross/target/bin - export PATH=$PATH:/tmp/osxcross/target/bin
- wget https://yapb.jeefo.net/ci/scripts/gitrev.sh && chmod a+x ./gitrev.sh && ./gitrev.sh - wget https://yapb.jeefo.net/ci/scripts/gitrev.sh && chmod a+x ./gitrev.sh && ./gitrev.sh
script: script:
- cd project && make all - cd project && CC=clang-3.8 make all
after_success: after_success:
- curl --ftp-create-dirs -T ./release/yapb.so -u $FTP_USER:$FTP_PASS ftp://$FTP_HOST/project/release/yapb.so - curl --ftp-create-dirs -T ./release/yapb.so -u $FTP_USER:$FTP_PASS ftp://$FTP_HOST/project/release/yapb.so
- curl --ftp-create-dirs -T ./debug/yapb.so -u $FTP_USER:$FTP_PASS ftp://$FTP_HOST/project/debug/yapb.so - curl --ftp-create-dirs -T ./debug/yapb.so -u $FTP_USER:$FTP_PASS ftp://$FTP_HOST/project/debug/yapb.so

View file

@ -6,123 +6,105 @@
# Additional exceptions apply. For full license details, see LICENSE.txt or visit: # Additional exceptions apply. For full license details, see LICENSE.txt or visit:
# https://yapb.jeefo.net/license # https://yapb.jeefo.net/license
# #
# Based on Makefile written by David "BAILOPAN" Anderson.
#
PROJECT = yapb PROJECT = yapb
SRC_DIR = ../source SOURCES = ../source
OBJECTS = $(SRC_DIR)/basecode.cpp \ OBJECTS = $(wildcard $(SOURCES)/*.cpp)
$(SRC_DIR)/manager.cpp \
$(SRC_DIR)/chatlib.cpp \
$(SRC_DIR)/combat.cpp \
$(SRC_DIR)/globals.cpp \
$(SRC_DIR)/engine.cpp \
$(SRC_DIR)/interface.cpp \
$(SRC_DIR)/navigate.cpp \
$(SRC_DIR)/support.cpp \
$(SRC_DIR)/waypoint.cpp \
C_OPT_FLAGS = -Ofast -DNDEBUG -pipe -fno-strict-aliasing -mtune=generic COMPILER_FLAGS = -std=c++11 -m32 -Wall -Werror -Wextra -fno-exceptions -fno-rtti
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3 LINKER_FLAGS = -m32 -lm -ldl
C_GCC_FLAGS = -fvisibility=hidden ifeq "$(SSE_VERSION)" ""
CPP_GCC_FLAGS = -fvisibility-inlines-hidden COMPILER_SSE_VERSION = 2
CPP = clang-3.8
CPP_MAC = o32-clang
LINK =
INCLUDE = -I../include -I../include/engine
ifeq "$(MAC)" "true"
OS = Darwin
CPP_MAC = o32-clang
else else
OS := $(shell uname -s) COMPILER_SSE_VERSION = $(SSE_VERSION)
endif endif
ifeq "$(OS)" "Darwin"
CPP = $(CPP_MAC)
LIB_EXT = dylib
CFLAGS += -DOSX -D_OSX -DPOSIX
LINK += -dynamiclib -lstdc++ -mmacosx-version-min=10.5 -arch i386
else
LIB_EXT = so
CFLAGS += -DLINUX -D_LINUX -DPOSIX
LINK += -shared -lsupc++
endif
LINK += -m32 -lm -ldl
CFLAGS += -msse2 -std=c++11 -m32 -Wall -Werror -Wextra
CPPFLAGS += -fno-exceptions -fno-rtti
BINARY = $(PROJECT).$(LIB_EXT)
ifeq "$(DEBUG)" "true" ifeq "$(DEBUG)" "true"
BIN_DIR = debug COMPILER_FLAGS += -D_DEBUG -DDEBUG -g3
CFLAGS += $(C_DEBUG_FLAGS) BINARY_DIR = debug
else else
BIN_DIR = release COMPILER_FLAGS += -DNDEBUG -pipe -Ofast -msse$(COMPILER_SSE_VERSION) -funroll-loops -fomit-frame-pointer -fno-stack-protector -fvisibility=hidden -fvisibility-inlines-hidden
CFLAGS += $(C_OPT_FLAGS) BINARY_DIR = release
endif
ifneq "$(OS)" "Darwin" INCLUDE = -I../include -I../include/engine
LINK += -s COMPILER = $(CC)
ifeq "$(shell uname -s)" "Darwin"
MACOS = true
else
ifeq "$(MACOS)" "true"
COMPILER = o32-clang
endif endif
endif endif
IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0") ifeq "$(MACOS)" "true"
LIBRARY_EXT = dylib
ifeq "$(IS_CLANG)" "1" COMPILER_FLAGS += -DOSX -D_OSX -DPOSIX
CFLAGS += $(C_GCC_FLAGS) -D__extern_always_inline="extern __always_inline" LINKER_FLAGS += -s -dynamiclib -lstdc++ -mmacosx-version-min=10.5 -arch i386
CPPFLAGS += $(CPP_GCC_FLAGS) else
LIBRARY_EXT = so
COMPILER_FLAGS += -DLINUX -D_LINUX -DPOSIX
LINKER_FLAGS += -shared -lsupc++
endif endif
# OS is Linux and not using clang BINARY_OUTPUT = $(PROJECT).$(LIBRARY_EXT)
ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1"
LINK += -static-libgcc ifeq ($(findstring clang,$(COMPILER)),clang)
COMPILER_FLAGS += -D__extern_always_inline="extern __always_inline"
ifeq "$(MACOS)" "false"
LINKER_FLAGS += -lgcc_eh
endif
else ifeq ($(findstring gcc,$(COMPILER)),gcc)
ifneq "$(MACOS)" "false"
LINKER_FLAGS += -static-libgcc
COMPILER_FLAGS += -funroll-all-loops
endif
else ifeq ($(findstring icpc,$(COMPILER)),icpc)
COMPILER_FLAGS += -funroll-all-loops -no-prec-div -no-inline-min-size -no-inline-max-size -wd11076 -wd11074
LINKER_FLAGS += -static-intel -no-intel-extensions
else
$(error Compiler unrecognized. Specify CC.)
endif endif
# OS is Linux and using clang OBJECTS_BIN := $(OBJECTS:%.cpp=$(BINARY_DIR)/%.o)
ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 1)" "1"
LINK += -lgcc_eh
endif
OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o) $(BINARY_DIR)/%.o: %.cpp
$(COMPILER) $(INCLUDE) $(COMPILER_FLAGS) -o $(subst $(SOURCES)/,,$@) -c $<
$(BIN_DIR)/%.o: %.cpp compile:
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $(subst $(SRC_DIR)/,,$@) -c $< mkdir -p $(BINARY_DIR)
main:
mkdir -p release
mkdir -p debug
$(MAKE) $(PROJECT) $(MAKE) $(PROJECT)
$(PROJECT): $(OBJ_BIN) $(PROJECT): $(OBJECTS_BIN)
$(CPP) $(INCLUDE) $(subst $(SRC_DIR)/,,$(OBJ_BIN)) $(LINK) -o $(BIN_DIR)/$(BINARY) $(COMPILER) $(INCLUDE) $(subst $(SOURCES)/,,$(OBJECTS_BIN)) $(LINKER_FLAGS) -o $(BINARY_DIR)/$(BINARY_OUTPUT)
debug:
mkdir -p debug
$(MAKE) main DEBUG=true
release: release:
mkdir -p release $(MAKE) compile DEBUG=false
$(MAKE) main DEBUG=false
release_osx: debug:
mkdir -p release $(MAKE) compile DEBUG=true
$(MAKE) main OSX=true DEBUG=false
debug_osx: release_macos:
mkdir -p debug $(MAKE) compile MACOS=true DEBUG=false
$(MAKE) main OSX=true DEBUG=true
all_linux: release debug debug_macos:
all_osx: release_osx debug_osx $(MAKE) compile MACOS=true DEBUG=true
all: all_linux all_osx
default: all all_linux:
$(MAKE) compile DEBUG=true
$(MAKE) compile DEBUG=false
all_macos:
$(MAKE) compile MACOS=true DEBUG=false
$(MAKE) compile MACOS=true DEBUG=true
all: all_linux all_macos
default: all_linux
clean: clean:
rm -rf release rm -rf release/*.o
rm -rf debug rm -rf release/$(BINARY_OUTPUT)
rm -rf debug/*.o
rm -rf debug/$(BINARY_OUTPUT)

View file

@ -1712,7 +1712,7 @@ void Bot::PurchaseWeapons (void)
else // steam cs buy menu is different from old one else // steam cs buy menu is different from old one
{ {
if (engine.GetTeam (GetEntity ()) == TERRORIST) if (m_team == TERRORIST)
engine.IssueBotCommand (GetEntity (), "menuselect %d", selectedWeapon->newBuySelectT); engine.IssueBotCommand (GetEntity (), "menuselect %d", selectedWeapon->newBuySelectT);
else else
engine.IssueBotCommand (GetEntity (), "menuselect %d", selectedWeapon->newBuySelectCT); engine.IssueBotCommand (GetEntity (), "menuselect %d", selectedWeapon->newBuySelectCT);
@ -2929,7 +2929,7 @@ void Bot::ThinkFrame (void)
m_voteMap = 0; m_voteMap = 0;
} }
} }
else if (m_notKilled && m_buyingFinished && !(pev->maxspeed < 10.0f && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) && !yb_freeze_bots.GetBool ()) else if (m_notKilled && m_buyingFinished && !(pev->maxspeed < 10.0f && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) && !yb_freeze_bots.GetBool () && !waypoints.HasChanged ())
botMovement = true; botMovement = true;
#ifdef XASH_CSDM #ifdef XASH_CSDM
@ -2955,9 +2955,13 @@ void Bot::PeriodicThink (void)
m_numFriendsLeft = GetNearbyFriendsNearPosition (pev->origin, 99999.0f); m_numFriendsLeft = GetNearbyFriendsNearPosition (pev->origin, 99999.0f);
m_numEnemiesLeft = GetNearbyEnemiesNearPosition (pev->origin, 99999.0f); m_numEnemiesLeft = GetNearbyEnemiesNearPosition (pev->origin, 99999.0f);
if (g_bombPlanted && m_team == CT && (pev->origin - waypoints.GetBombPosition ()).GetLength () < 700 && !IsBombDefusing (waypoints.GetBombPosition ()) && !m_hasProgressBar && GetTaskId () != TASK_ESCAPEFROMBOMB) if (g_bombPlanted && m_team == CT)
ResetTasks (); {
const Vector &bombPosition = waypoints.GetBombPosition ();
if (!m_hasProgressBar && GetTaskId () != TASK_ESCAPEFROMBOMB && (pev->origin - bombPosition).GetLength () < 700 && !IsBombDefusing ())
ResetTasks ();
}
CheckSpawnTimeConditions (); CheckSpawnTimeConditions ();
extern ConVar yb_chat; extern ConVar yb_chat;
@ -3559,10 +3563,10 @@ void Bot::RunTask_Camp (void)
dest.z = 0.0f; dest.z = 0.0f;
// find a visible waypoint to this direction... // find a visible waypoint to this direction...
// i know this is ugly hack, but i just don't want to break compatiability :) // i know this is ugly hack, but i just don't want to break compatibility :)
int numFoundPoints = 0; int numFoundPoints = 0;
int foundPoints[3]; int campPoints[3] = { 0, };
int distanceTab[3]; int distances[3] = { 0, };
const Vector &dotA = (dest - pev->origin).Normalize2D (); const Vector &dotA = (dest - pev->origin).Normalize2D ();
@ -3574,7 +3578,7 @@ void Bot::RunTask_Camp (void)
const Vector &dotB = (waypoints.GetPath (i)->origin - pev->origin).Normalize2D (); const Vector &dotB = (waypoints.GetPath (i)->origin - pev->origin).Normalize2D ();
if ((dotA | dotB) > 0.9) if ((dotA | dotB) > 0.9f)
{ {
int distance = static_cast <int> ((pev->origin - waypoints.GetPath (i)->origin).GetLength ()); int distance = static_cast <int> ((pev->origin - waypoints.GetPath (i)->origin).GetLength ());
@ -3582,10 +3586,10 @@ void Bot::RunTask_Camp (void)
{ {
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
{ {
if (distance > distanceTab[j]) if (distance > distances[j])
{ {
distanceTab[j] = distance; distances[j] = distance;
foundPoints[j] = i; campPoints[j] = i;
break; break;
} }
@ -3593,8 +3597,8 @@ void Bot::RunTask_Camp (void)
} }
else else
{ {
foundPoints[numFoundPoints] = i; campPoints[numFoundPoints] = i;
distanceTab[numFoundPoints] = distance; distances[numFoundPoints] = distance;
numFoundPoints++; numFoundPoints++;
} }
@ -3602,7 +3606,7 @@ void Bot::RunTask_Camp (void)
} }
if (--numFoundPoints >= 0) if (--numFoundPoints >= 0)
m_camp = waypoints.GetPath (foundPoints[Random.Int (0, numFoundPoints)])->origin; m_camp = waypoints.GetPath (campPoints[Random.Int (0, numFoundPoints)])->origin;
else else
m_camp = waypoints.GetPath (GetCampAimingWaypoint ())->origin; m_camp = waypoints.GetPath (GetCampAimingWaypoint ())->origin;
} }

View file

@ -157,25 +157,26 @@ WeaponSelect g_weaponSelect[NUM_WEAPONS + 1] =
{0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, false} {0, "", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, false}
}; };
// bot menus void SetupBotMenus (void)
MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
{ {
// main menu int counter = 0;
// bots main menu
g_menus[counter] =
{ {
BOT_MENU_MAIN, BOT_MENU_MAIN, 0x2ff,
0x2ff,
"\\yMain Menu\\w\v\v" "\\yMain Menu\\w\v\v"
"1. Control Bots\v" "1. Control Bots\v"
"2. Features\v\v" "2. Features\v\v"
"3. Fill Server\v" "3. Fill Server\v"
"4. End Round\v\v" "4. End Round\v\v"
"0. Exit" "0. Exit"
}, };
// bot features menu // bots features menu
g_menus[++counter] =
{ {
BOT_MENU_FEATURES, BOT_MENU_FEATURES, 0x25f,
0x25f,
"\\yBots Features\\w\v\v" "\\yBots Features\\w\v\v"
"1. Weapon Mode Menu\v" "1. Weapon Mode Menu\v"
"2. Waypoint Menu\v" "2. Waypoint Menu\v"
@ -183,12 +184,12 @@ MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
"4. Toggle Debug Mode\v" "4. Toggle Debug Mode\v"
"5. Command Menu\v\v" "5. Command Menu\v\v"
"0. Exit" "0. Exit"
}, };
// bot control menu // bot control menu
g_menus[++counter] =
{ {
BOT_MENU_CONTROL, BOT_MENU_CONTROL, 0x2ff,
0x2ff,
"\\yBots Control Menu\\w\v\v" "\\yBots Control Menu\\w\v\v"
"1. Add a Bot, Quick\v" "1. Add a Bot, Quick\v"
"2. Add a Bot, Specified\v\v" "2. Add a Bot, Specified\v\v"
@ -196,12 +197,12 @@ MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
"4. Remove All Bots\v\v" "4. Remove All Bots\v\v"
"5. Remove Bot Menu\v\v" "5. Remove Bot Menu\v\v"
"0. Exit" "0. Exit"
}, };
// weapon mode select menu // weapon mode select menu
g_menus[++counter] =
{ {
BOT_MENU_WEAPON_MODE, BOT_MENU_WEAPON_MODE, 0x27f,
0x27f,
"\\yBots Weapon Mode\\w\v\v" "\\yBots Weapon Mode\\w\v\v"
"1. Knives only\v" "1. Knives only\v"
"2. Pistols only\v" "2. Pistols only\v"
@ -211,24 +212,24 @@ MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
"6. Sniper Weapons only\v" "6. Sniper Weapons only\v"
"7. All Weapons\v\v" "7. All Weapons\v\v"
"0. Exit" "0. Exit"
}, };
// personality select menu // personality select menu
g_menus[++counter] =
{ {
BOT_MENU_PERSONALITY, BOT_MENU_PERSONALITY, 0x20f,
0x20f,
"\\yBots Personality\\w\v\v" "\\yBots Personality\\w\v\v"
"1. Random\v" "1. Random\v"
"2. Normal\v" "2. Normal\v"
"3. Aggressive\v" "3. Aggressive\v"
"4. Careful\v\v" "4. Careful\v\v"
"0. Exit" "0. Exit"
}, };
// difficulty select menu // difficulty select menu
g_menus[++counter] =
{ {
BOT_MENU_DIFFICULTY, BOT_MENU_DIFFICULTY, 0x23f,
0x23f,
"\\yBots Difficulty Level\\w\v\v" "\\yBots Difficulty Level\\w\v\v"
"1. Newbie\v" "1. Newbie\v"
"2. Average\v" "2. Average\v"
@ -236,23 +237,23 @@ MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
"4. Professional\v" "4. Professional\v"
"5. Godlike\v\v" "5. Godlike\v\v"
"0. Exit" "0. Exit"
}, };
// team select menu // team select menu
g_menus[++counter] =
{ {
BOT_MENU_TEAM_SELECT, BOT_MENU_TEAM_SELECT, 0x213,
0x213,
"\\ySelect a team\\w\v\v" "\\ySelect a team\\w\v\v"
"1. Terrorist Force\v" "1. Terrorist Force\v"
"2. Counter-Terrorist Force\v\v" "2. Counter-Terrorist Force\v\v"
"5. Auto-select\v\v" "5. Auto-select\v\v"
"0. Exit" "0. Exit"
}, };
// terrorist model select menu // terrorist model select menu
g_menus[++counter] =
{ {
BOT_MENU_TERRORIST_SELECT, BOT_MENU_TERRORIST_SELECT, 0x21f,
0x21f,
"\\ySelect an appearance\\w\v\v" "\\ySelect an appearance\\w\v\v"
"1. Phoenix Connexion\v" "1. Phoenix Connexion\v"
"2. L337 Krew\v" "2. L337 Krew\v"
@ -260,12 +261,12 @@ MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
"4. Guerilla Warfare\v\v" "4. Guerilla Warfare\v\v"
"5. Auto-select\v\v" "5. Auto-select\v\v"
"0. Exit" "0. Exit"
}, };
// counter-terrorist model select menu // counter-terrorist model select menu
g_menus[++counter] =
{ {
BOT_MENU_CT_SELECT, BOT_MENU_CT_SELECT, 0x21f,
0x21f,
"\\ySelect an appearance\\w\v\v" "\\ySelect an appearance\\w\v\v"
"1. Seal Team 6 (DEVGRU)\v" "1. Seal Team 6 (DEVGRU)\v"
"2. German GSG-9\v" "2. German GSG-9\v"
@ -273,24 +274,24 @@ MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
"4. French GIGN\v\v" "4. French GIGN\v\v"
"5. Auto-select\v\v" "5. Auto-select\v\v"
"0. Exit" "0. Exit"
}, };
// command menu // command menu
g_menus[++counter] =
{ {
BOT_MENU_COMMANDS, BOT_MENU_COMMANDS, 0x23f,
0x23f,
"\\yBot Command Menu\\w\v\v" "\\yBot Command Menu\\w\v\v"
"1. Make Double Jump\v" "1. Make Double Jump\v"
"2. Finish Double Jump\v\v" "2. Finish Double Jump\v\v"
"3. Drop the C4 Bomb\v" "3. Drop the C4 Bomb\v"
"4. Drop the Weapon\v\v" "4. Drop the Weapon\v\v"
"0. Exit" "0. Exit"
}, };
// main waypoint menu // main waypoint menu
g_menus[++counter] =
{ {
BOT_MENU_WAYPOINT_MAIN_PAGE1, BOT_MENU_WAYPOINT_MAIN_PAGE1, 0x3ff,
0x3ff,
"\\yWaypoint Operations (Page 1)\\w\v\v" "\\yWaypoint Operations (Page 1)\\w\v\v"
"1. Show/Hide waypoints\v" "1. Show/Hide waypoints\v"
"2. Cache waypoint\v" "2. Cache waypoint\v"
@ -302,12 +303,12 @@ MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
"8. Set Radius\v\v" "8. Set Radius\v\v"
"9. Next...\v\v" "9. Next...\v\v"
"0. Exit" "0. Exit"
}, };
// main waypoint menu (page 2) // main waypoint menu (page 2)
g_menus[++counter] =
{ {
BOT_MENU_WAYPOINT_MAIN_PAGE2, BOT_MENU_WAYPOINT_MAIN_PAGE2, 0x3ff,
0x3ff,
"\\yWaypoint Operations (Page 2)\\w\v\v" "\\yWaypoint Operations (Page 2)\\w\v\v"
"1. Waypoint stats\v" "1. Waypoint stats\v"
"2. Autowaypoint on/off\v" "2. Autowaypoint on/off\v"
@ -319,12 +320,12 @@ MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
"8. Noclip cheat on/off\v\v" "8. Noclip cheat on/off\v\v"
"9. Previous...\v\v" "9. Previous...\v\v"
"0. Exit" "0. Exit"
}, };
// select waypoint radius menu // select waypoint radius menu
g_menus[++counter] =
{ {
BOT_MENU_WAYPOINT_RADIUS, BOT_MENU_WAYPOINT_RADIUS, 0x3ff,
0x3ff,
"\\yWaypoint Radius\\w\v\v" "\\yWaypoint Radius\\w\v\v"
"1. SetRadius 0\v" "1. SetRadius 0\v"
"2. SetRadius 8\v" "2. SetRadius 8\v"
@ -336,12 +337,12 @@ MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
"8. SetRadius 96\v" "8. SetRadius 96\v"
"9. SetRadius 128\v\v" "9. SetRadius 128\v\v"
"0. Exit" "0. Exit"
}, };
// waypoint add menu // waypoint add menu
g_menus[++counter] =
{ {
BOT_MENU_WAYPOINT_TYPE, BOT_MENU_WAYPOINT_TYPE, 0x3ff,
0x3ff,
"\\yWaypoint Type\\w\v\v" "\\yWaypoint Type\\w\v\v"
"1. Normal\v" "1. Normal\v"
"\\r2. Terrorist Important\v" "\\r2. Terrorist Important\v"
@ -353,12 +354,12 @@ MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
"\\r8. Map Goal\v" "\\r8. Map Goal\v"
"\\w9. Jump\v\v" "\\w9. Jump\v\v"
"0. Exit" "0. Exit"
}, };
// set waypoint flag menu // set waypoint flag menu
g_menus[++counter] =
{ {
BOT_MENU_WAYPOINT_FLAG, BOT_MENU_WAYPOINT_FLAG, 0x2ff,
0x2ff,
"\\yToggle Waypoint Flags\\w\v\v" "\\yToggle Waypoint Flags\\w\v\v"
"1. Block with Hostage\v" "1. Block with Hostage\v"
"2. Terrorists Specific\v" "2. Terrorists Specific\v"
@ -366,9 +367,10 @@ MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
"4. Use Elevator\v" "4. Use Elevator\v"
"5. Sniper Point (\\yFor Camp Points Only!\\w)\v\v" "5. Sniper Point (\\yFor Camp Points Only!\\w)\v\v"
"0. Exit" "0. Exit"
}, };
// auto-path max distance // auto-path max distance
g_menus[++counter] =
{ {
BOT_MENU_WAYPOINT_AUTOPATH, BOT_MENU_WAYPOINT_AUTOPATH,
0x27f, 0x27f,
@ -381,9 +383,10 @@ MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
"6. Distance 220\v" "6. Distance 220\v"
"7. Distance 250 (Default)\v\v" "7. Distance 250 (Default)\v\v"
"0. Exit" "0. Exit"
}, };
// path connections // path connections
g_menus[++counter] =
{ {
BOT_MENU_WAYPOINT_PATH, BOT_MENU_WAYPOINT_PATH,
0x207, 0x207,
@ -392,33 +395,16 @@ MenuText g_menus[BOT_MENU_TOTAL_MENUS] =
"2. Incoming Path\v" "2. Incoming Path\v"
"3. Bidirectional (Both Ways)\v\v" "3. Bidirectional (Both Ways)\v\v"
"0. Exit" "0. Exit"
}, };
// kickmenu #1 const String &empty = "";
{
BOT_MENU_KICK_PAGE_1,
0x0,
nullptr,
},
// kickmenu #2 // kick menus
{ g_menus[++counter] = { BOT_MENU_KICK_PAGE_1, 0x0, empty, };
BOT_MENU_KICK_PAGE_2, g_menus[++counter] = { BOT_MENU_KICK_PAGE_2, 0x0, empty, };
0x0, g_menus[++counter] = { BOT_MENU_KICK_PAGE_3, 0x0, empty, };
nullptr, g_menus[++counter] = { BOT_MENU_KICK_PAGE_4, 0x0, empty, };
}, }
// kickmenu #3 // bot menus
{ MenuText g_menus[BOT_MENU_TOTAL_MENUS];
BOT_MENU_KICK_PAGE_3,
0x0,
nullptr,
},
// kickmenu #4
{
BOT_MENU_KICK_PAGE_4,
0x0,
nullptr,
}
};

View file

@ -1236,14 +1236,20 @@ void ClientCommand (edict_t *ent)
case 6: case 6:
case 7: case 7:
waypoints.Add (selection - 1); waypoints.Add (selection - 1);
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_TYPE);
break; break;
case 8: case 8:
waypoints.Add (100); waypoints.Add (100);
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_TYPE);
break; break;
case 9: case 9:
waypoints.SetLearnJumpWaypoint (); waypoints.SetLearnJumpWaypoint ();
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_TYPE);
break; break;
case 10: case 10:
@ -1263,22 +1269,27 @@ void ClientCommand (edict_t *ent)
{ {
case 1: case 1:
waypoints.ToggleFlags (FLAG_NOHOSTAGE); waypoints.ToggleFlags (FLAG_NOHOSTAGE);
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_FLAG);
break; break;
case 2: case 2:
waypoints.ToggleFlags (FLAG_TF_ONLY); waypoints.ToggleFlags (FLAG_TF_ONLY);
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_FLAG);
break; break;
case 3: case 3:
waypoints.ToggleFlags (FLAG_CF_ONLY); waypoints.ToggleFlags (FLAG_CF_ONLY);
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_FLAG);
break; break;
case 4: case 4:
waypoints.ToggleFlags (FLAG_LIFT); waypoints.ToggleFlags (FLAG_LIFT);
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_FLAG);
break; break;
case 5: case 5:
waypoints.ToggleFlags (FLAG_SNIPER); waypoints.ToggleFlags (FLAG_SNIPER);
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_FLAG);
break; break;
} }
if (g_gameFlags & GAME_METAMOD) if (g_gameFlags & GAME_METAMOD)
@ -1297,11 +1308,15 @@ void ClientCommand (edict_t *ent)
engine.IssueCmd ("yapb waypoint off"); engine.IssueCmd ("yapb waypoint off");
else else
engine.IssueCmd ("yapb waypoint on"); engine.IssueCmd ("yapb waypoint on");
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_MAIN_PAGE1);
break; break;
case 2: case 2:
g_waypointOn = true; g_waypointOn = true;
waypoints.CacheWaypoint (); waypoints.CacheWaypoint ();
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_MAIN_PAGE1);
break; break;
case 3: case 3:
@ -1312,6 +1327,8 @@ void ClientCommand (edict_t *ent)
case 4: case 4:
g_waypointOn = true; g_waypointOn = true;
waypoints.DeletePath (); waypoints.DeletePath ();
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_MAIN_PAGE1);
break; break;
case 5: case 5:
@ -1322,6 +1339,8 @@ void ClientCommand (edict_t *ent)
case 6: case 6:
g_waypointOn = true; g_waypointOn = true;
waypoints.Delete (); waypoints.Delete ();
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_MAIN_PAGE1);
break; break;
case 7: case 7:
@ -1392,6 +1411,8 @@ void ClientCommand (edict_t *ent)
"CT Points: %d - Goal Points: %d\n" "CT Points: %d - Goal Points: %d\n"
"Rescue Points: %d - Camp Points: %d\n" "Rescue Points: %d - Camp Points: %d\n"
"Block Hostage Points: %d - Sniper Points: %d\n", g_numWaypoints, terrPoints, ctPoints, goalPoints, rescuePoints, campPoints, noHostagePoints, sniperPoints); "Block Hostage Points: %d - Sniper Points: %d\n", g_numWaypoints, terrPoints, ctPoints, goalPoints, rescuePoints, campPoints, noHostagePoints, sniperPoints);
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_MAIN_PAGE2);
} }
break; break;
@ -1401,6 +1422,8 @@ void ClientCommand (edict_t *ent)
g_autoWaypoint ^= 1; g_autoWaypoint ^= 1;
engine.CenterPrintf ("Auto-Waypoint %s", g_autoWaypoint ? "Enabled" : "Disabled"); engine.CenterPrintf ("Auto-Waypoint %s", g_autoWaypoint ? "Enabled" : "Disabled");
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_MAIN_PAGE2);
break; break;
case 3: case 3:
@ -1413,14 +1436,18 @@ void ClientCommand (edict_t *ent)
waypoints.Save (); waypoints.Save ();
else else
engine.CenterPrintf ("Waypoint not saved\nThere are errors, see console"); engine.CenterPrintf ("Waypoint not saved\nThere are errors, see console");
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_MAIN_PAGE2);
break; break;
case 5: case 5:
waypoints.Save (); waypoints.Save ();
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_MAIN_PAGE2);
break; break;
case 6: case 6:
waypoints.Load (); waypoints.Load ();
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_MAIN_PAGE2);
break; break;
case 7: case 7:
@ -1428,10 +1455,13 @@ void ClientCommand (edict_t *ent)
engine.CenterPrintf ("Nodes works fine"); engine.CenterPrintf ("Nodes works fine");
else else
engine.CenterPrintf ("There are errors, see console"); engine.CenterPrintf ("There are errors, see console");
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_MAIN_PAGE2);
break; break;
case 8: case 8:
engine.IssueCmd ("yapb wp on noclip"); engine.IssueCmd ("yapb wp on noclip");
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_MAIN_PAGE2);
break; break;
case 9: case 9:
@ -1454,6 +1484,8 @@ void ClientCommand (edict_t *ent)
if ((selection >= 1) && (selection <= 9)) if ((selection >= 1) && (selection <= 9))
waypoints.SetRadius (radiusValue[selection - 1]); waypoints.SetRadius (radiusValue[selection - 1]);
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_RADIUS);
if (g_gameFlags & GAME_METAMOD) if (g_gameFlags & GAME_METAMOD)
RETURN_META (MRES_SUPERCEDE); RETURN_META (MRES_SUPERCEDE);
@ -1481,6 +1513,7 @@ void ClientCommand (edict_t *ent)
case 4: case 4:
bots.KillAll (); bots.KillAll ();
DisplayMenuToClient (ent, BOT_MENU_MAIN);
break; break;
case 10: case 10:
@ -1501,6 +1534,7 @@ void ClientCommand (edict_t *ent)
{ {
case 1: case 1:
bots.AddRandom (); bots.AddRandom ();
DisplayMenuToClient (ent, BOT_MENU_CONTROL);
break; break;
case 2: case 2:
@ -1509,10 +1543,12 @@ void ClientCommand (edict_t *ent)
case 3: case 3:
bots.RemoveRandom (); bots.RemoveRandom ();
DisplayMenuToClient (ent, BOT_MENU_CONTROL);
break; break;
case 4: case 4:
bots.RemoveAll (); bots.RemoveAll ();
DisplayMenuToClient (ent, BOT_MENU_CONTROL);
break; break;
case 5: case 5:
@ -1550,6 +1586,7 @@ void ClientCommand (edict_t *ent)
extern ConVar yb_debug; extern ConVar yb_debug;
yb_debug.SetInt (yb_debug.GetInt () ^ 1); yb_debug.SetInt (yb_debug.GetInt () ^ 1);
DisplayMenuToClient (ent, BOT_MENU_FEATURES);
break; break;
case 5: case 5:
@ -1596,16 +1633,17 @@ void ClientCommand (edict_t *ent)
} }
else if (selection == 2) else if (selection == 2)
bot->ResetDoubleJumpState (); bot->ResetDoubleJumpState ();
break;
} }
} }
DisplayMenuToClient (ent, BOT_MENU_COMMANDS);
break; break;
case 3: case 3:
case 4: case 4:
if (FindNearestPlayer (reinterpret_cast <void **> (&bot), ent, 300.0f, true, true, true)) if (FindNearestPlayer (reinterpret_cast <void **> (&bot), ent, 300.0f, true, true, true))
bot->DiscardWeaponForUser (ent, selection == 4 ? false : true); bot->DiscardWeaponForUser (ent, selection == 4 ? false : true);
DisplayMenuToClient (ent, BOT_MENU_COMMANDS);
break; break;
case 10: case 10:
@ -1618,7 +1656,7 @@ void ClientCommand (edict_t *ent)
return; return;
} }
else if (client->menu ==BOT_MENU_WAYPOINT_AUTOPATH) else if (client->menu == BOT_MENU_WAYPOINT_AUTOPATH)
{ {
DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display DisplayMenuToClient (ent, BOT_MENU_INVALID); // reset menu display
@ -1632,6 +1670,8 @@ void ClientCommand (edict_t *ent)
else else
engine.CenterPrintf ("AutoPath maximum distance set to %.2f", g_autoPathDistance); engine.CenterPrintf ("AutoPath maximum distance set to %.2f", g_autoPathDistance);
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_AUTOPATH);
if (g_gameFlags & GAME_METAMOD) if (g_gameFlags & GAME_METAMOD)
RETURN_META (MRES_SUPERCEDE); RETURN_META (MRES_SUPERCEDE);
@ -1645,14 +1685,17 @@ void ClientCommand (edict_t *ent)
{ {
case 1: case 1:
waypoints.CreatePath (CONNECTION_OUTGOING); waypoints.CreatePath (CONNECTION_OUTGOING);
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_PATH);
break; break;
case 2: case 2:
waypoints.CreatePath (CONNECTION_INCOMING); waypoints.CreatePath (CONNECTION_INCOMING);
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_PATH);
break; break;
case 3: case 3:
waypoints.CreatePath (CONNECTION_BOTHWAYS); waypoints.CreatePath (CONNECTION_BOTHWAYS);
DisplayMenuToClient (ent, BOT_MENU_WAYPOINT_PATH);
break; break;
case 10: case 10:
@ -1847,6 +1890,7 @@ void ClientCommand (edict_t *ent)
case 6: case 6:
case 7: case 7:
bots.SetWeaponMode (selection); bots.SetWeaponMode (selection);
DisplayMenuToClient (ent, BOT_MENU_WEAPON_MODE);
break; break;
case 10: case 10:
@ -1873,6 +1917,7 @@ void ClientCommand (edict_t *ent)
case 7: case 7:
case 8: case 8:
bots.GetBot (selection - 1)->Kick (); bots.GetBot (selection - 1)->Kick ();
bots.RemoveMenu (ent, 1);
break; break;
case 9: case 9:
@ -1903,6 +1948,7 @@ void ClientCommand (edict_t *ent)
case 7: case 7:
case 8: case 8:
bots.GetBot (selection + 8 - 1)->Kick (); bots.GetBot (selection + 8 - 1)->Kick ();
bots.RemoveMenu (ent, 2);
break; break;
case 9: case 9:
@ -1933,6 +1979,7 @@ void ClientCommand (edict_t *ent)
case 7: case 7:
case 8: case 8:
bots.GetBot (selection + 16 - 1)->Kick (); bots.GetBot (selection + 16 - 1)->Kick ();
bots.RemoveMenu (ent, 3);
break; break;
case 9: case 9:
@ -1963,6 +2010,7 @@ void ClientCommand (edict_t *ent)
case 7: case 7:
case 8: case 8:
bots.GetBot (selection + 24 - 1)->Kick (); bots.GetBot (selection + 24 - 1)->Kick ();
bots.RemoveMenu (ent, 4);
break; break;
case 10: case 10:

View file

@ -572,12 +572,14 @@ void BotManager::RemoveMenu (edict_t *ent, int selection)
int validSlots = (selection == 4) ? (1 << 9) : ((1 << 8) | (1 << 9)); int validSlots = (selection == 4) ? (1 << 9) : ((1 << 8) | (1 << 9));
for (int i = ((selection - 1) * 8); i < selection * 8; i++) for (int i = (selection - 1) * 8; i < selection * 8; i++)
{ {
if (m_bots[i] != nullptr && !engine.IsNullEntity (m_bots[i]->GetEntity ())) const Bot *bot = GetBot (i);
if (bot != nullptr && (bot->pev->flags & FL_FAKECLIENT))
{ {
validSlots |= 1 << (i - ((selection - 1) * 8)); validSlots |= 1 << (i - ((selection - 1) * 8));
sprintf (buffer, "%s %1.1d. %s%s\n", buffer, i - ((selection - 1) * 8) + 1, STRING (m_bots[i]->pev->netname), engine.GetTeam (m_bots[i]->GetEntity ()) == CT ? " \\y(CT)\\w" : " \\r(T)\\w"); sprintf (buffer, "%s %1.1d. %s%s\n", buffer, i - ((selection - 1) * 8) + 1, STRING (bot->pev->netname), bot->m_team == CT ? " \\y(CT)\\w" : " \\r(T)\\w");
} }
else else
sprintf (buffer, "%s\\d %1.1d. Not a Bot\\w\n", buffer, i - ((selection - 1) * 8) + 1); sprintf (buffer, "%s\\d %1.1d. Not a Bot\\w\n", buffer, i - ((selection - 1) * 8) + 1);
@ -585,32 +587,58 @@ void BotManager::RemoveMenu (edict_t *ent, int selection)
sprintf (tempBuffer, "\\yBots Remove Menu (%d/4):\\w\n\n%s\n%s 0. Back", selection, buffer, (selection == 4) ? "" : " 9. More...\n"); sprintf (tempBuffer, "\\yBots Remove Menu (%d/4):\\w\n\n%s\n%s 0. Back", selection, buffer, (selection == 4) ? "" : " 9. More...\n");
// force to clear current menu
DisplayMenuToClient (ent, BOT_MENU_INVALID);
auto FindMenu = [] (MenuId id)
{
int menuIndex = 0;
for (; menuIndex < ARRAYSIZE_HLSDK (g_menus); menuIndex++)
{
if (g_menus[menuIndex].id == id)
break;
}
return &g_menus[menuIndex];
};
MenuText *menu = nullptr;
const unsigned int slots = validSlots & static_cast <unsigned int> (-1);
switch (selection) switch (selection)
{ {
case 1: case 1:
g_menus[BOT_MENU_KICK_PAGE_1].slots = validSlots & static_cast <unsigned int> (-1); menu = FindMenu (BOT_MENU_KICK_PAGE_1);
g_menus[14].text = tempBuffer;
menu->slots = slots;
menu->text = tempBuffer;
DisplayMenuToClient (ent, BOT_MENU_KICK_PAGE_1); DisplayMenuToClient (ent, BOT_MENU_KICK_PAGE_1);
break; break;
case 2: case 2:
g_menus[BOT_MENU_KICK_PAGE_2].slots = validSlots & static_cast <unsigned int> (-1); menu = FindMenu (BOT_MENU_KICK_PAGE_2);
g_menus[BOT_MENU_KICK_PAGE_2].text = tempBuffer;
menu->slots = slots;
menu->text = tempBuffer;
DisplayMenuToClient (ent, BOT_MENU_KICK_PAGE_2); DisplayMenuToClient (ent, BOT_MENU_KICK_PAGE_2);
break; break;
case 3: case 3:
g_menus[BOT_MENU_KICK_PAGE_3].slots = validSlots & static_cast <unsigned int> (-1); menu = FindMenu (BOT_MENU_KICK_PAGE_3);
g_menus[BOT_MENU_KICK_PAGE_3].text = tempBuffer;
menu->slots = slots;
menu->text = tempBuffer;
DisplayMenuToClient (ent, BOT_MENU_KICK_PAGE_3); DisplayMenuToClient (ent, BOT_MENU_KICK_PAGE_3);
break; break;
case 4: case 4:
g_menus[BOT_MENU_KICK_PAGE_4].slots = validSlots & static_cast <unsigned int> (-1); menu = FindMenu (BOT_MENU_KICK_PAGE_4);
g_menus[BOT_MENU_KICK_PAGE_4].text = tempBuffer;
menu->slots = slots;
menu->text = tempBuffer;
DisplayMenuToClient (ent, BOT_MENU_KICK_PAGE_4); DisplayMenuToClient (ent, BOT_MENU_KICK_PAGE_4);
break; break;
@ -1265,6 +1293,9 @@ void Bot::Kick (bool keepQuota)
{ {
// this function kick off one bot from the server. // this function kick off one bot from the server.
// clear fakeclient bit immediately
pev->flags &= ~FL_FAKECLIENT;
engine.IssueCmd ("kick \"%s\"", STRING (pev->netname)); engine.IssueCmd ("kick \"%s\"", STRING (pev->netname));
engine.CenterPrintf ("Bot '%s' kicked", STRING (pev->netname)); engine.CenterPrintf ("Bot '%s' kicked", STRING (pev->netname));

View file

@ -106,6 +106,9 @@ void DisplayMenuToClient (edict_t *ent, MenuId menu)
// make menus looks like we need only once // make menus looks like we need only once
if (!s_menusParsed) if (!s_menusParsed)
{ {
extern void SetupBotMenus (void);
SetupBotMenus ();
for (int i = 0; i < ARRAYSIZE_HLSDK (g_menus); i++) for (int i = 0; i < ARRAYSIZE_HLSDK (g_menus); i++)
{ {
auto parsed = &g_menus[i]; auto parsed = &g_menus[i];