Merge pull request #459 from diamante0018/develop
[Vote] Improvements and other things
This commit is contained in:
commit
4370de45aa
@ -314,7 +314,7 @@ namespace Components
|
||||
|
||||
bool Gamepad::GPad_Check(const int gamePadIndex, const int portIndex)
|
||||
{
|
||||
assert((portIndex >= 0) && (portIndex < Game::MAX_GPAD_COUNT));
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
|
||||
@ -422,7 +422,7 @@ namespace Components
|
||||
|
||||
bool Gamepad::AimAssist_IsLockonActive(const int gamePadIndex)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
|
||||
auto& aaGlob = Game::aaGlobArray[gamePadIndex];
|
||||
|
||||
@ -827,7 +827,7 @@ namespace Components
|
||||
|
||||
void Gamepad::CL_GamepadMove(const int gamePadIndex, Game::usercmd_s* cmd, const float frameTimeBase)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
auto& clientActive = Game::clients[gamePadIndex];
|
||||
@ -970,7 +970,7 @@ namespace Components
|
||||
|
||||
void Gamepad::CL_GamepadResetMenuScrollTime(const int gamePadIndex, const int key, const bool down, const unsigned time)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
|
||||
auto& gamePadGlobal = gamePadGlobals[gamePadIndex];
|
||||
|
||||
@ -990,7 +990,7 @@ namespace Components
|
||||
|
||||
void Gamepad::CL_GamepadGenerateAPad(const int gamePadIndex, const Game::GamepadPhysicalAxis physicalAxis, unsigned time)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
assert(physicalAxis >= 0 && physicalAxis < Game::GPAD_PHYSAXIS_COUNT);
|
||||
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
@ -1025,7 +1025,7 @@ namespace Components
|
||||
|
||||
void Gamepad::CL_GamepadEvent(const int gamePadIndex, const Game::GamepadPhysicalAxis physicalAxis, const float value, const unsigned time)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
assert(physicalAxis >= 0 && physicalAxis < Game::GPAD_PHYSAXIS_COUNT);
|
||||
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
@ -1126,7 +1126,7 @@ namespace Components
|
||||
|
||||
void Gamepad::CL_GamepadButtonEvent(const int gamePadIndex, const int key, const Game::GamePadButtonEvent buttonEvent, const unsigned time)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
|
||||
const auto pressed = buttonEvent == Game::GPAD_BUTTON_PRESSED;
|
||||
const auto pressedOrUpdated = pressed || buttonEvent == Game::GPAD_BUTTON_UPDATE;
|
||||
@ -1212,9 +1212,9 @@ namespace Components
|
||||
|
||||
void Gamepad::CL_GamepadButtonEventForPort(const int gamePadIndex, const int key, const Game::GamePadButtonEvent buttonEvent, const unsigned time)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
gamePad.inUse = true;
|
||||
gpad_in_use.setRaw(true);
|
||||
|
||||
@ -1257,7 +1257,7 @@ namespace Components
|
||||
|
||||
float Gamepad::GPad_GetStick(const int gamePadIndex, const Game::GamePadStick stick)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
assert(stick & Game::GPAD_STICK_MASK);
|
||||
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
@ -1267,7 +1267,7 @@ namespace Components
|
||||
|
||||
float Gamepad::GPad_GetButton(const int gamePadIndex, Game::GamePadButton button)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
|
||||
float value = 0.0f;
|
||||
@ -1291,7 +1291,7 @@ namespace Components
|
||||
|
||||
bool Gamepad::GPad_IsButtonPressed(const int gamePadIndex, Game::GamePadButton button)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
assert(button & (Game::GPAD_DIGITAL_MASK | Game::GPAD_ANALOG_MASK));
|
||||
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
@ -1327,7 +1327,7 @@ namespace Components
|
||||
|
||||
bool Gamepad::GPad_IsButtonReleased(int gamePadIndex, Game::GamePadButton button)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
|
||||
@ -1358,7 +1358,7 @@ namespace Components
|
||||
|
||||
void Gamepad::GPad_UpdateSticksDown(const int gamePadIndex)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
|
||||
@ -1390,7 +1390,7 @@ namespace Components
|
||||
|
||||
void Gamepad::GPad_UpdateSticks(const int gamePadIndex, const XINPUT_GAMEPAD& state)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
|
||||
@ -1422,7 +1422,7 @@ namespace Components
|
||||
|
||||
void Gamepad::GPad_UpdateDigitals(const int gamePadIndex, const XINPUT_GAMEPAD& state)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
|
||||
@ -1444,7 +1444,7 @@ namespace Components
|
||||
|
||||
void Gamepad::GPad_UpdateAnalogs(const int gamePadIndex, const XINPUT_GAMEPAD& state)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
|
||||
auto& gamePad = gamePads[gamePadIndex];
|
||||
|
||||
@ -1559,7 +1559,7 @@ namespace Components
|
||||
|
||||
void Gamepad::Gamepad_WriteBindings(const int gamePadIndex, const int handle)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
|
||||
auto& gamePadGlobal = gamePadGlobals[gamePadIndex];
|
||||
|
||||
@ -1612,7 +1612,7 @@ namespace Components
|
||||
|
||||
void Gamepad::Gamepad_BindAxis(const int gamePadIndex, const Game::GamepadPhysicalAxis realIndex, const Game::GamepadVirtualAxis axisIndex, const Game::GamepadMapping mapType)
|
||||
{
|
||||
assert(gamePadIndex < Game::MAX_GPAD_COUNT);
|
||||
AssertIn(gamePadIndex, Game::MAX_GPAD_COUNT);
|
||||
assert(realIndex > Game::GPAD_PHYSAXIS_NONE && realIndex < Game::GPAD_PHYSAXIS_COUNT);
|
||||
assert(axisIndex > Game::GPAD_VIRTAXIS_NONE && axisIndex < Game::GPAD_VIRTAXIS_COUNT);
|
||||
assert(mapType > Game::GPAD_MAP_NONE && mapType < Game::GPAD_MAP_COUNT);
|
||||
|
@ -96,12 +96,12 @@ namespace Components
|
||||
|
||||
const char* Maps::LoadArenaFileStub(const char* name, char* buffer, int size)
|
||||
{
|
||||
std::string data = Game::Scr_AddSourceBuffer(nullptr, name, nullptr, false);
|
||||
std::string data = RawFiles::ReadRawFile(name, buffer, size);
|
||||
|
||||
if (Maps::UserMap.isValid())
|
||||
{
|
||||
std::string mapname = Maps::UserMap.getName();
|
||||
std::string arena = Utils::String::VA("usermaps/%s/%s.arena", mapname.data(), mapname.data());
|
||||
const std::string mapname = Maps::UserMap.getName();
|
||||
const auto* arena = Utils::String::VA("usermaps/%s/%s.arena", mapname.data(), mapname.data());
|
||||
|
||||
if (Utils::IO::FileExists(arena))
|
||||
{
|
||||
@ -109,7 +109,7 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
strncpy_s(buffer, size, data.data(), data.size());
|
||||
strncpy_s(buffer, size, data.data(), _TRUNCATE);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -806,7 +806,7 @@ namespace Components
|
||||
}
|
||||
|
||||
// Not quite sure if we want to do this if we're not ingame, but it's only needed for ingame menus.
|
||||
if (Dvar::Var("cl_ingame").get<bool>())
|
||||
if ((*Game::cl_ingame)->current.enabled)
|
||||
{
|
||||
Game::Key_SetCatcher(0, 16);
|
||||
}
|
||||
|
@ -7,8 +7,9 @@ namespace Components
|
||||
public:
|
||||
RawFiles();
|
||||
|
||||
private:
|
||||
static char* ReadRawFile(const char* filename, char* buf, int size);
|
||||
|
||||
private:
|
||||
static char* GetMenuBuffer(const char* filename);
|
||||
};
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace Components
|
||||
{
|
||||
std::unordered_map<std::string, Utils::Slot<UIScript::Callback>> UIScript::UIScripts;
|
||||
std::unordered_map<int, Utils::Slot<UIScript::CallbackRaw>> UIScript::UIOwnerDraws;
|
||||
std::unordered_map<std::string, UIScript::UIScriptHandler> UIScript::UIScripts;
|
||||
std::unordered_map<int, std::function<void()>> UIScript::UIOwnerDraws;
|
||||
|
||||
template<> int UIScript::Token::get() const
|
||||
{
|
||||
@ -49,22 +49,22 @@ namespace Components
|
||||
return &Game::uiInfoArray[localClientNum];
|
||||
}
|
||||
|
||||
void UIScript::Add(const std::string& name, const Utils::Slot<UIScript::Callback>& callback)
|
||||
void UIScript::Add(const std::string& name, const UIScript::UIScriptHandler& callback)
|
||||
{
|
||||
UIScript::UIScripts[name] = callback;
|
||||
}
|
||||
|
||||
void UIScript::AddOwnerDraw(int ownerdraw, const Utils::Slot<UIScript::CallbackRaw>& callback)
|
||||
void UIScript::AddOwnerDraw(int ownerdraw, const std::function<void()>& callback)
|
||||
{
|
||||
UIScript::UIOwnerDraws[ownerdraw] = callback;
|
||||
}
|
||||
|
||||
bool UIScript::RunMenuScript(const char* name, const char** args)
|
||||
{
|
||||
if (UIScript::UIScripts.contains(name))
|
||||
if (const auto got = UIScript::UIScripts.find(name); got != UIScript::UIScripts.end())
|
||||
{
|
||||
const auto* info = UIScript::UI_GetClientInfo(0);
|
||||
UIScript::UIScripts[name](UIScript::Token(args), info);
|
||||
got->second(UIScript::Token(args), info);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -24,20 +24,19 @@ namespace Components
|
||||
void parse(const char** args);
|
||||
};
|
||||
|
||||
typedef void(Callback)(const Token& token, const Game::uiInfo_s* info);
|
||||
typedef void(CallbackRaw)();
|
||||
using UIScriptHandler = std::function<void(const Token& token, const Game::uiInfo_s* info)>;
|
||||
|
||||
static Game::uiInfo_s* UI_GetClientInfo(int localClientNum);
|
||||
|
||||
static void Add(const std::string& name, const Utils::Slot<Callback>& callback);
|
||||
static void AddOwnerDraw(int ownerdraw, const Utils::Slot<CallbackRaw>& callback);
|
||||
static void Add(const std::string& name, const UIScriptHandler& callback);
|
||||
static void AddOwnerDraw(int ownerdraw, const std::function<void()>& callback);
|
||||
|
||||
private:
|
||||
static void OwnerDrawHandleKeyStub(int ownerDraw, int flags, float *special, int key);
|
||||
static bool RunMenuScript(const char* name, const char** args);
|
||||
static void RunMenuScriptStub();
|
||||
|
||||
static std::unordered_map<std::string, Utils::Slot<Callback>> UIScripts;
|
||||
static std::unordered_map<int, Utils::Slot<CallbackRaw>> UIOwnerDraws;
|
||||
static std::unordered_map<std::string, UIScriptHandler> UIScripts;
|
||||
static std::unordered_map<int, std::function<void()>> UIOwnerDraws;
|
||||
};
|
||||
}
|
||||
|
@ -64,9 +64,10 @@ namespace Components
|
||||
strncpy_s(arg2, params->get(2), _TRUNCATE);
|
||||
strncpy_s(arg3, params->get(3), _TRUNCATE);
|
||||
|
||||
if (!MapRotation::Contains("gametype", arg2) ||
|
||||
!MapRotation::Contains("map", arg3))
|
||||
// This prevents abuse
|
||||
if (!MapRotation::Contains("map", arg3))
|
||||
{
|
||||
Game::SV_GameSendServerCommand(ent - Game::g_entities, Game::SV_CMD_CAN_IGNORE, VA("%c \"GAME_NOTONROTATION\"", 0x65));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -124,8 +125,10 @@ namespace Components
|
||||
|
||||
bool Vote::HandleMap([[maybe_unused]] const Game::gentity_s* ent, [[maybe_unused]] const Command::ServerParams* params)
|
||||
{
|
||||
// This prevents abuse
|
||||
if (!MapRotation::Contains("map", params->get(2)))
|
||||
{
|
||||
Game::SV_GameSendServerCommand(ent - Game::g_entities, Game::SV_CMD_CAN_IGNORE, VA("%c \"GAME_NOTONROTATION\"", 0x65));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -136,11 +139,6 @@ namespace Components
|
||||
|
||||
bool Vote::HandleGametype([[maybe_unused]] const Game::gentity_s* ent, [[maybe_unused]] const Command::ServerParams* params)
|
||||
{
|
||||
if (!MapRotation::Contains("gametype", params->get(2)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Game::Scr_IsValidGameType(params->get(2)))
|
||||
{
|
||||
Game::SV_GameSendServerCommand(ent - Game::g_entities, Game::SV_CMD_CAN_IGNORE, VA("%c \"GAME_INVALIDGAMETYPE\"", 0x65));
|
||||
@ -342,7 +340,7 @@ namespace Components
|
||||
UIScript::Add("voteTypeMap", []([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info)
|
||||
{
|
||||
Game::Cbuf_AddText(0, VA("callvote typemap %s %s\n", Game::sharedUiInfo->gameTypes[(*Game::ui_netGameType)->current.integer].gameType,
|
||||
Game::sharedUiInfo->mapList[(*Game::ui_netGameType)->current.integer].mapName));
|
||||
Game::sharedUiInfo->mapList[(*Game::ui_currentMap)->current.integer].mapName));
|
||||
});
|
||||
|
||||
UIScript::Add("voteMap", []([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info)
|
||||
|
@ -44,6 +44,7 @@ namespace Game
|
||||
|
||||
const dvar_t** cl_showSend = reinterpret_cast<const dvar_t**>(0xA1E870);
|
||||
const dvar_t** cl_voice = reinterpret_cast<const dvar_t**>(0xB2BB44);
|
||||
const dvar_t** cl_ingame = reinterpret_cast<const dvar_t**>(0xB2BB80);
|
||||
|
||||
const dvar_t** g_cheats = reinterpret_cast<const dvar_t**>(0x1A45D54);
|
||||
const dvar_t** g_deadChat = reinterpret_cast<const dvar_t**>(0x19BD5DC);
|
||||
|
@ -100,6 +100,7 @@ namespace Game
|
||||
|
||||
extern const dvar_t** cl_showSend;
|
||||
extern const dvar_t** cl_voice;
|
||||
extern const dvar_t** cl_ingame;
|
||||
|
||||
extern const dvar_t** g_cheats;
|
||||
extern const dvar_t** g_deadChat;
|
||||
|
@ -216,6 +216,7 @@ namespace Game
|
||||
UI_KeyEvent_t UI_KeyEvent = UI_KeyEvent_t(0x4970F0);
|
||||
UI_SafeTranslateString_t UI_SafeTranslateString = UI_SafeTranslateString_t(0x4F1700);
|
||||
UI_ReplaceConversions_t UI_ReplaceConversions = UI_ReplaceConversions_t(0x4E9740);
|
||||
UI_ParseInfos_t UI_ParseInfos = UI_ParseInfos_t(0x4027A0);
|
||||
|
||||
Win_GetLanguage_t Win_GetLanguage = Win_GetLanguage_t(0x45CBA0);
|
||||
|
||||
@ -418,6 +419,10 @@ namespace Game
|
||||
int* g_largeLocalPos = reinterpret_cast<int*>(0x63D97B4);
|
||||
int* g_largeLocalRightPos = reinterpret_cast<int*>(0x63D9780);
|
||||
|
||||
char** ui_arenaInfos = reinterpret_cast<char**>(0x62D2688);
|
||||
int* ui_numArenas = reinterpret_cast<int*>(0x62D2788);
|
||||
int* ui_arenaBufPos = reinterpret_cast<int*>(0x62D278C);
|
||||
|
||||
const char* TableLookup(StringTable* stringtable, int row, int column)
|
||||
{
|
||||
if (!stringtable || !stringtable->values || row >= stringtable->rowCount || column >= stringtable->columnCount) return "";
|
||||
|
@ -239,6 +239,9 @@ namespace Game
|
||||
typedef void(*UI_ReplaceConversions_t)(const char* sourceString, ConversionArguments* arguments, char* outputString, size_t outputStringSize);
|
||||
extern UI_ReplaceConversions_t UI_ReplaceConversions;
|
||||
|
||||
typedef int(*UI_ParseInfos_t)(const char* buf, int max, char** infos);
|
||||
extern UI_ParseInfos_t UI_ParseInfos;
|
||||
|
||||
typedef void(*MSG_Init_t)(msg_t* buf, unsigned char* data, int length);
|
||||
extern MSG_Init_t MSG_Init;
|
||||
|
||||
@ -768,6 +771,10 @@ namespace Game
|
||||
extern int* g_largeLocalPos;
|
||||
extern int* g_largeLocalRightPos;
|
||||
|
||||
extern char** ui_arenaInfos;
|
||||
extern int* ui_numArenas;
|
||||
extern int* ui_arenaBufPos;
|
||||
|
||||
ScreenPlacement* ScrPlace_GetFullPlacement();
|
||||
ScreenPlacement* ScrPlace_GetUnsafeFullPlacement();
|
||||
|
||||
|
@ -5666,18 +5666,16 @@ namespace Game
|
||||
UILOCALVAR_STRING = 0x2,
|
||||
};
|
||||
|
||||
union $B42A88463653BDCDFC5664844B4491DA
|
||||
{
|
||||
int integer;
|
||||
float value;
|
||||
const char *string;
|
||||
};
|
||||
|
||||
struct UILocalVar
|
||||
{
|
||||
UILocalVarType type;
|
||||
const char* name;
|
||||
$B42A88463653BDCDFC5664844B4491DA u;
|
||||
union
|
||||
{
|
||||
int integer;
|
||||
float value;
|
||||
const char* string;
|
||||
} u;
|
||||
};
|
||||
|
||||
struct UILocalVarContext
|
||||
@ -5685,20 +5683,18 @@ namespace Game
|
||||
UILocalVar table[256];
|
||||
};
|
||||
|
||||
struct $1942E78D15753E2013144570239460A8
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
int lastMoveTime;
|
||||
};
|
||||
|
||||
struct UiContext
|
||||
{
|
||||
int localClientNum;
|
||||
float bias;
|
||||
int realTime;
|
||||
int frameTime;
|
||||
$1942E78D15753E2013144570239460A8 cursor;
|
||||
struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
int lastMoveTime;
|
||||
} cursor;
|
||||
int isCursorVisible;
|
||||
int paintFull;
|
||||
int screenWidth;
|
||||
|
@ -54,7 +54,7 @@ namespace Utils
|
||||
if (size > -1)
|
||||
{
|
||||
data->resize(static_cast<uint32_t>(size));
|
||||
stream.read(const_cast<char*>(data->data()), size);
|
||||
stream.read(data->data(), size);
|
||||
stream.close();
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user