Moved cgi.protocol to a new variable called cg_protocol instead, due to issues like GetCGameAPI being loaded before having client imports (cgi)

This commit is contained in:
OM 2023-07-02 19:16:09 +02:00
parent fa69717bed
commit 36dce22071
9 changed files with 17 additions and 21 deletions

View file

@ -1210,7 +1210,7 @@ void CG_DrawSpectatorView_ver_6()
}
void CG_DrawSpectatorView() {
if (cgi.protocol >= PROTOCOL_MOHTA_MIN) {
if (cg_protocol >= PROTOCOL_MOHTA_MIN) {
CG_DrawSpectatorView_ver_15();
} else {
CG_DrawSpectatorView_ver_6();

View file

@ -359,9 +359,9 @@ typedef struct {
typedef struct {
gameState_t gameState; // gamestate from server
glconfig_t glconfig; // rendering configuration
float screenXScale; // derived from glconfig
float screenYScale;
float screenXBias;
float screenXScale; // derived from glconfig
float screenYScale;
float screenXBias;
int serverCommandSequence; // reliable command stream counter
int processedSnapshotNum;// the number of snapshots cgame has requested
@ -402,6 +402,7 @@ extern cvar_t* developer;
extern cgs_t cgs;
extern cg_t cg;
extern clientGameImport_t cgi;
extern int cg_protocol;
extern centity_t cg_entities[MAX_GENTITIES];
extern markPoly_t cg_markPolys[MAX_MARK_POLYS];

View file

@ -31,11 +31,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#endif
clientGameImport_t cgi;
static clientGameExport_t cge;
cvar_t* paused;
cvar_t* developer;
cg_t cg;
cgs_t cgs;
int cg_protocol;
centity_t cg_entities[MAX_GENTITIES];
cvar_t* cg_animSpeed;
@ -587,6 +589,10 @@ void CG_Init(clientGameImport_t* imported, int serverMessageNum,
cgi.Free = &CG_Free;
#endif
cg_protocol = cgi.Cvar_Get("com_protocol", "", 0)->integer;
CG_InitCGMessageAPI(&cge);
CG_InitScoresAPI(&cge);
memset(&cg, 0, sizeof(cg));
memset(&cgs, 0, sizeof(cgs));
@ -675,8 +681,6 @@ The only exported function from this module
*/
clientGameExport_t *GetCGameAPI(void)
{
static clientGameExport_t cge;
cge.CG_Init = CG_Init;
cge.CG_DrawActiveFrame = CG_DrawActiveFrame;
cge.CG_Shutdown = CG_Shutdown;
@ -701,9 +705,6 @@ clientGameExport_t *GetCGameAPI(void)
cge.CG_WeaponCommandButtonBits = CG_WeaponCommandButtonBits;
cge.CG_CheckCaptureKey = CG_CheckCaptureKey;
CG_InitCGMessageAPI(&cge);
CG_InitScoresAPI(&cge);
// FIXME
//cge.profStruct = NULL;
@ -821,7 +822,7 @@ void CG_ParseFogInfo_ver_6(const char* str) {
}
void CG_ParseFogInfo(const char* str) {
if (cgi.protocol >= PROTOCOL_MOHTA_MIN) {
if (cg_protocol >= PROTOCOL_MOHTA_MIN) {
CG_ParseFogInfo_ver_15(str);
} else {
CG_ParseFogInfo_ver_6(str);

View file

@ -30,7 +30,7 @@ void CG_PlayerTeamIcon(refEntity_t* pModel, entityState_t* pPlayerState)
{
qboolean bInArtillery, bInTeam, bSpecialIcon;
if (cgi.protocol < PROTOCOL_MOHTA_MIN)
if (cg_protocol < PROTOCOL_MOHTA_MIN)
{
if (pPlayerState->eFlags & EF_ALLIES)
{

View file

@ -1147,7 +1147,7 @@ void CG_ParseCGMessage_ver_6()
}
void CG_InitCGMessageAPI(clientGameExport_t* cge)
{ if (cgi.protocol >= PROTOCOL_MOHTA_MIN) {
{ if (cg_protocol >= PROTOCOL_MOHTA_MIN) {
cge->CG_ParseCGMessage = &CG_ParseCGMessage_ver_15;
} else {
cge->CG_ParseCGMessage = &CG_ParseCGMessage_ver_6;

View file

@ -360,9 +360,6 @@ typedef struct
clientAnim_t* anim;
stopWatch_t* stopWatch;
target_game_e targetGame;
protocol_e protocol;
} clientGameImport_t;

View file

@ -719,7 +719,7 @@ void CG_ParseScores_ver_6()
void CG_ParseScores()
{
if (cgi.protocol >= PROTOCOL_MOHTA_MIN) {
if (cg_protocol >= PROTOCOL_MOHTA_MIN) {
CG_ParseScores_ver_15();
} else {
CG_ParseScores_ver_6();
@ -733,7 +733,7 @@ void CG_InitScoresAPI(clientGameExport_t* cge)
cge->CG_GetScoreBoardPosition = CG_GetScoreBoardPosition;
cge->CG_GetScoreBoardDrawHeader = CG_GetScoreBoardDrawHeader;
if (cgi.protocol >= PROTOCOL_MOHTA_MIN) {
if (cg_protocol >= PROTOCOL_MOHTA_MIN) {
cge->CG_GetColumnName = &CG_GetColumnName_ver_15;
} else {
cge->CG_GetColumnName = &CG_GetColumnName_ver_6;

View file

@ -225,7 +225,7 @@ static void CG_Stopwatch_f()
Com_Error(ERR_DROP, "stopwatch didn't have 2 parameters");
}
if (cgi.protocol >= PROTOCOL_MOHTA_MIN) {
if (cg_protocol >= PROTOCOL_MOHTA_MIN) {
cgi.stopWatch->iStartTime = atoi(cgi.Argv(1));
} else {
// The base game has it wrong

View file

@ -758,9 +758,6 @@ void CL_InitCGameDLL( clientGameImport_t *cgi, clientGameExport_t **cge ) {
// FIXME
//cgi->pUnknownVar = NULL;
cgi->targetGame = (target_game_e)com_target_game->integer;
cgi->protocol = (protocol_e)com_protocol->integer;
cls.cgameStarted = qtrue;
}