spraycan: fix cvar not being updated properly
GetCVar returns a per-player copy of the requested cvar, which is only used to have separate values for each player - changes are propagated To it, but not From it. writing to this cvar is only useful if you know what the actual new value is going to be & want the cvar to update Immediately. (in this case, the cvar needs to be updated before A_SetHelpText so the displayed spray name is correct) FindCVar returns the actual cvar for the local player. changes to this cvar Are propagated to other clients.
This commit is contained in:
parent
333c40e46a
commit
f4bf7a793e
@ -322,8 +322,12 @@ class SnekTechSprayer : HDWeapon
|
||||
int newIndex = (currentIndex + 1) % patternList.size();
|
||||
|
||||
// Set the new CVar.
|
||||
CVar.GetCVar("snektech_spraypattern", owner.player).SetString(patternList[newIndex]);
|
||||
currentPattern = CVar.GetCVar("snektech_spraypattern", owner.player).GetString();
|
||||
currentPattern = patternList[newIndex];
|
||||
// first, update the Actual cvar
|
||||
if (owner.PlayerNumber() == consoleplayer)
|
||||
CVar.FindCVar("snektech_spraypattern").SetString(currentPattern);
|
||||
// then update the per-player copy so the help text is correct
|
||||
CVar.GetCVar("snektech_spraypattern", owner.player).SetString(currentPattern);
|
||||
owner.A_Log("Selected spray pattern: "..currentPattern, true);
|
||||
|
||||
// Current pattern is referenced in the help text, so reset
|
||||
|
Loading…
Reference in New Issue
Block a user