mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 12:11:25 +00:00
- fixed startup-time setup of serverinfo CVARs.
Looks I completely forgot this part when refactoring the interface - it must account for the callbacks not doing anything due to the network code not being operational yet.
This commit is contained in:
parent
6722b64ac0
commit
17df95d69e
4 changed files with 45 additions and 45 deletions
|
@ -172,7 +172,7 @@ void FBaseCVar::SetGenericRep (UCVarValue value, ECVarType type)
|
|||
{
|
||||
return;
|
||||
}
|
||||
else if ((Flags & CVAR_LATCH) && callbacks && callbacks->MustLatch())
|
||||
if ((Flags & CVAR_LATCH) && callbacks && callbacks->MustLatch())
|
||||
{
|
||||
FLatchedValue latch;
|
||||
|
||||
|
@ -186,15 +186,13 @@ void FBaseCVar::SetGenericRep (UCVarValue value, ECVarType type)
|
|||
LatchedValues.Push (latch);
|
||||
|
||||
Flags &= ~CVAR_UNSAFECONTEXT;
|
||||
return;
|
||||
}
|
||||
else if ((Flags & CVAR_SERVERINFO) && callbacks && callbacks->SendServerInfoChange)
|
||||
if ((Flags & CVAR_SERVERINFO) && callbacks && callbacks->SendServerInfoChange)
|
||||
{
|
||||
callbacks->SendServerInfoChange (this, value, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
ForceSet (value, type);
|
||||
if (callbacks->SendServerInfoChange(this, value, type)) return;
|
||||
}
|
||||
ForceSet (value, type);
|
||||
}
|
||||
|
||||
bool FBaseCVar::ToBool (UCVarValue value, ECVarType type)
|
||||
|
@ -969,17 +967,14 @@ void FFlagCVar::DoSet (UCVarValue value, ECVarType type)
|
|||
// another flag might have made to the same cvar earlier in the script.
|
||||
if (ValueVar.GetFlags() && callbacks && callbacks->SendServerFlagChange)
|
||||
{
|
||||
callbacks->SendServerFlagChange(&ValueVar, BitNum, newval, false);
|
||||
if (callbacks->SendServerFlagChange(&ValueVar, BitNum, newval, false)) return;
|
||||
}
|
||||
int val = *ValueVar;
|
||||
if (newval)
|
||||
val |= BitVal;
|
||||
else
|
||||
{
|
||||
int val = *ValueVar;
|
||||
if (newval)
|
||||
val |= BitVal;
|
||||
else
|
||||
val &= ~BitVal;
|
||||
ValueVar = val;
|
||||
}
|
||||
val &= ~BitVal;
|
||||
ValueVar = val;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1072,13 +1067,14 @@ void FMaskCVar::DoSet (UCVarValue value, ECVarType type)
|
|||
{
|
||||
if (BitVal & (1<<i))
|
||||
{
|
||||
callbacks->SendServerFlagChange (&ValueVar, i, !!(val & (1<<i)), silent);
|
||||
if (!callbacks->SendServerFlagChange(&ValueVar, i, !!(val & (1 << i)), silent)) goto fallback; // the failure case here is either always or never.
|
||||
silent = true; // only warn once if SendServerFlagChange needs to.
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fallback:
|
||||
int vval = *ValueVar;
|
||||
vval &= ~BitVal;
|
||||
vval |= val;
|
||||
|
|
|
@ -109,8 +109,8 @@ class FBaseCVar;
|
|||
struct ConsoleCallbacks
|
||||
{
|
||||
void (*UserInfoChanged)(FBaseCVar*);
|
||||
void (*SendServerInfoChange)(FBaseCVar* cvar, UCVarValue value, ECVarType type);
|
||||
void (*SendServerFlagChange)(FBaseCVar* cvar, int bitnum, bool set, bool silent);
|
||||
bool (*SendServerInfoChange)(FBaseCVar* cvar, UCVarValue value, ECVarType type);
|
||||
bool (*SendServerFlagChange)(FBaseCVar* cvar, int bitnum, bool set, bool silent);
|
||||
FBaseCVar* (*GetUserCVar)(int playernum, const char* cvarname);
|
||||
bool (*MustLatch)();
|
||||
|
||||
|
|
|
@ -54,8 +54,8 @@ void D_SetupUserInfo (void);
|
|||
|
||||
void D_UserInfoChanged (FBaseCVar *info);
|
||||
|
||||
void D_SendServerInfoChange (FBaseCVar *cvar, UCVarValue value, ECVarType type);
|
||||
void D_SendServerFlagChange (FBaseCVar *cvar, int bitnum, bool set, bool silent);
|
||||
bool D_SendServerInfoChange (FBaseCVar *cvar, UCVarValue value, ECVarType type);
|
||||
bool D_SendServerFlagChange (FBaseCVar *cvar, int bitnum, bool set, bool silent);
|
||||
void D_DoServerInfoChange (uint8_t **stream, bool singlebit);
|
||||
|
||||
void D_WriteUserInfoStrings (int player, uint8_t **stream, bool compact=false);
|
||||
|
|
|
@ -623,7 +623,7 @@ static const char *SetServerVar (char *name, ECVarType type, uint8_t **stream, b
|
|||
|
||||
EXTERN_CVAR (Float, sv_gravity)
|
||||
|
||||
void D_SendServerInfoChange (FBaseCVar *cvar, UCVarValue value, ECVarType type)
|
||||
bool D_SendServerInfoChange (FBaseCVar *cvar, UCVarValue value, ECVarType type)
|
||||
{
|
||||
if (gamestate != GS_STARTUP && !demoplayback)
|
||||
{
|
||||
|
@ -631,43 +631,47 @@ void D_SendServerInfoChange (FBaseCVar *cvar, UCVarValue value, ECVarType type)
|
|||
{
|
||||
Printf("Only setting controllers can change %s\n", cvar->GetName());
|
||||
cvar->MarkSafe();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
size_t namelen;
|
||||
size_t namelen;
|
||||
|
||||
namelen = strlen (cvar->GetName ());
|
||||
namelen = strlen(cvar->GetName());
|
||||
|
||||
Net_WriteByte (DEM_SINFCHANGED);
|
||||
Net_WriteByte ((uint8_t)(namelen | (type << 6)));
|
||||
Net_WriteBytes ((uint8_t *)cvar->GetName (), (int)namelen);
|
||||
switch (type)
|
||||
{
|
||||
case CVAR_Bool: Net_WriteByte (value.Bool); break;
|
||||
case CVAR_Int: Net_WriteLong (value.Int); break;
|
||||
case CVAR_Float: Net_WriteFloat (value.Float); break;
|
||||
case CVAR_String: Net_WriteString (value.String); break;
|
||||
default: break; // Silence GCC
|
||||
Net_WriteByte(DEM_SINFCHANGED);
|
||||
Net_WriteByte((uint8_t)(namelen | (type << 6)));
|
||||
Net_WriteBytes((uint8_t*)cvar->GetName(), (int)namelen);
|
||||
switch (type)
|
||||
{
|
||||
case CVAR_Bool: Net_WriteByte(value.Bool); break;
|
||||
case CVAR_Int: Net_WriteLong(value.Int); break;
|
||||
case CVAR_Float: Net_WriteFloat(value.Float); break;
|
||||
case CVAR_String: Net_WriteString(value.String); break;
|
||||
default: break; // Silence GCC
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void D_SendServerFlagChange (FBaseCVar *cvar, int bitnum, bool set, bool silent)
|
||||
bool D_SendServerFlagChange (FBaseCVar *cvar, int bitnum, bool set, bool silent)
|
||||
{
|
||||
if (gamestate != GS_STARTUP && !demoplayback)
|
||||
{
|
||||
if (netgame && !players[consoleplayer].settings_controller)
|
||||
{
|
||||
if (!silent) Printf("Only setting controllers can change %s\n", cvar->GetName());
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
int namelen = (int)strlen(cvar->GetName());
|
||||
|
||||
Net_WriteByte(DEM_SINFCHANGEDXOR);
|
||||
Net_WriteByte((uint8_t)namelen);
|
||||
Net_WriteBytes((uint8_t*)cvar->GetName(), namelen);
|
||||
Net_WriteByte(uint8_t(bitnum | (set << 5)));
|
||||
return true;
|
||||
}
|
||||
|
||||
int namelen = (int)strlen (cvar->GetName ());
|
||||
|
||||
Net_WriteByte (DEM_SINFCHANGEDXOR);
|
||||
Net_WriteByte ((uint8_t)namelen);
|
||||
Net_WriteBytes ((uint8_t *)cvar->GetName (), namelen);
|
||||
Net_WriteByte (uint8_t(bitnum | (set << 5)));
|
||||
return false;
|
||||
}
|
||||
|
||||
void D_DoServerInfoChange (uint8_t **stream, bool singlebit)
|
||||
|
|
Loading…
Reference in a new issue