Fix some inconsistencies in my code

This commit is contained in:
FutureRave 2022-01-18 00:21:25 +00:00
parent 805be6bb01
commit 5c34e55552
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955
3 changed files with 15 additions and 15 deletions

View File

@ -185,8 +185,8 @@ namespace Components
return; return;
} }
g_botai[gentity->s.number] = {0}; g_botai[entref.entnum] = {0};
g_botai[gentity->s.number].weapon = 1; g_botai[entref.entnum].weapon = 1;
}); });
Script::AddFunction("BotWeapon", [](Game::scr_entref_t entref) // Usage: <bot> BotWeapon(<str>); Script::AddFunction("BotWeapon", [](Game::scr_entref_t entref) // Usage: <bot> BotWeapon(<str>);
@ -204,12 +204,12 @@ namespace Components
if (weapon[0] == '\0') if (weapon[0] == '\0')
{ {
g_botai[gentity->s.number].weapon = 1; g_botai[entref.entnum].weapon = 1;
return; return;
} }
const auto weapId = Game::G_GetWeaponIndexForName(weapon); const auto weapId = Game::G_GetWeaponIndexForName(weapon);
g_botai[gentity->s.number].weapon = static_cast<uint16_t>(weapId); g_botai[entref.entnum].weapon = static_cast<uint16_t>(weapId);
}); });
Script::AddFunction("BotAction", [](Game::scr_entref_t entref) // Usage: <bot> BotAction(<str action>); Script::AddFunction("BotAction", [](Game::scr_entref_t entref) // Usage: <bot> BotAction(<str action>);
@ -237,9 +237,9 @@ namespace Components
continue; continue;
if (action[0] == '+') if (action[0] == '+')
g_botai[gentity->s.number].buttons |= BotActions[i].key; g_botai[entref.entnum].buttons |= BotActions[i].key;
else else
g_botai[gentity->s.number].buttons &= ~(BotActions[i].key); g_botai[entref.entnum].buttons &= ~(BotActions[i].key);
return; return;
} }
@ -273,8 +273,8 @@ namespace Components
if (rightInt < -127) if (rightInt < -127)
rightInt = -127; rightInt = -127;
g_botai[gentity->s.number].forward = static_cast<int8_t>(forwardInt); g_botai[entref.entnum].forward = static_cast<int8_t>(forwardInt);
g_botai[gentity->s.number].right = static_cast<int8_t>(rightInt); g_botai[entref.entnum].right = static_cast<int8_t>(rightInt);
}); });
} }

View File

@ -17,7 +17,7 @@ namespace Components
if (ent->health < 1) if (ent->health < 1)
{ {
Logger::Print("CheatsOk: entity %u must be alive to use this command!\n", entNum); Logger::Print("CheatsOk: entity %i must be alive to use this command!\n", entNum);
Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"GAME_MUSTBEALIVECOMMAND\"", 0x65)); Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"GAME_MUSTBEALIVECOMMAND\"", 0x65));
return false; return false;
} }
@ -75,7 +75,7 @@ namespace Components
ent->client->flags ^= Game::PLAYER_FLAG_NOCLIP; ent->client->flags ^= Game::PLAYER_FLAG_NOCLIP;
const auto entNum = ent->s.number; const auto entNum = ent->s.number;
Logger::Print("Noclip toggled for entity %u\n", entNum); Logger::Print("Noclip toggled for entity %i\n", entNum);
Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65, Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65,
(ent->client->flags & Game::PLAYER_FLAG_NOCLIP) ? "GAME_NOCLIPON" : "GAME_NOCLIPOFF")); (ent->client->flags & Game::PLAYER_FLAG_NOCLIP) ? "GAME_NOCLIPON" : "GAME_NOCLIPOFF"));
@ -89,7 +89,7 @@ namespace Components
ent->client->flags ^= Game::PLAYER_FLAG_UFO; ent->client->flags ^= Game::PLAYER_FLAG_UFO;
const auto entNum = ent->s.number; const auto entNum = ent->s.number;
Logger::Print("UFO toggled for entity %u\n", entNum); Logger::Print("UFO toggled for entity %i\n", entNum);
Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65, Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65,
(ent->client->flags & Game::PLAYER_FLAG_UFO) ? "GAME_UFOON" : "GAME_UFOOFF")); (ent->client->flags & Game::PLAYER_FLAG_UFO) ? "GAME_UFOON" : "GAME_UFOOFF"));
@ -103,7 +103,7 @@ namespace Components
ent->flags ^= Game::FL_GODMODE; ent->flags ^= Game::FL_GODMODE;
const auto entNum = ent->s.number; const auto entNum = ent->s.number;
Logger::Print("God toggled for entity %u\n", entNum); Logger::Print("God toggled for entity %i\n", entNum);
Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65, Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65,
(ent->flags & Game::FL_GODMODE) ? "GAME_GODMODE_ON" : "GAME_GODMODE_OFF")); (ent->flags & Game::FL_GODMODE) ? "GAME_GODMODE_ON" : "GAME_GODMODE_OFF"));
@ -117,7 +117,7 @@ namespace Components
ent->flags ^= Game::FL_DEMI_GODMODE; ent->flags ^= Game::FL_DEMI_GODMODE;
const auto entNum = ent->s.number; const auto entNum = ent->s.number;
Logger::Print("Demigod toggled for entity %u\n", entNum); Logger::Print("Demigod toggled for entity %i\n", entNum);
Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65, Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65,
(ent->flags & Game::FL_DEMI_GODMODE) ? "GAME_DEMI_GODMODE_ON" : "GAME_DEMI_GODMODE_OFF")); (ent->flags & Game::FL_DEMI_GODMODE) ? "GAME_DEMI_GODMODE_ON" : "GAME_DEMI_GODMODE_OFF"));
@ -131,7 +131,7 @@ namespace Components
ent->flags ^= Game::FL_NOTARGET; ent->flags ^= Game::FL_NOTARGET;
const auto entNum = ent->s.number; const auto entNum = ent->s.number;
Logger::Print("Notarget toggled for entity %u\n", entNum); Logger::Print("Notarget toggled for entity %i\n", entNum);
Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65, Game::SV_GameSendServerCommand(entNum, 0, Utils::String::VA("%c \"%s\"", 0x65,
(ent->flags & Game::FL_NOTARGET) ? "GAME_NOTARGETON" : "GAME_NOTARGETOFF")); (ent->flags & Game::FL_NOTARGET) ? "GAME_NOTARGETON" : "GAME_NOTARGETOFF"));

View File

@ -55,7 +55,7 @@ namespace Components
return; return;
// If were are developing let's just print a brief message // If were are developing let's just print a brief message
// scrVmPub->debugCode seems to be always false // scrVmPub.debugCode seems to be always false
if (Game::scrVmPub->debugCode || Game::scrVarPub->developer_script) if (Game::scrVmPub->debugCode || Game::scrVarPub->developer_script)
{ {
Logger::Print(23, "%s\n", msg); Logger::Print(23, "%s\n", msg);