experimental fix for improving hud sync
This commit is contained in:
parent
83bf0d7b2a
commit
ccb3b4fbb3
@ -3902,8 +3902,7 @@ static cell AMX_NATIVE_CALL CreateHudSyncObj(AMX *amx, cell *params)
|
|||||||
return static_cast<cell>(g_hudsync.size());
|
return static_cast<cell>(g_hudsync.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
hudtextparms_t temp_hud_stuff;
|
void CheckAndClearPlayerHUD(CPlayer *player, int &channel, unsigned int sync_obj)
|
||||||
void CheckAndClearPlayerHUD(CPlayer *player, unsigned int channel, unsigned int sync_obj)
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* player and channel should be guaranteed to be good to go.
|
* player and channel should be guaranteed to be good to go.
|
||||||
@ -3915,27 +3914,8 @@ void CheckAndClearPlayerHUD(CPlayer *player, unsigned int channel, unsigned int
|
|||||||
//check if the last sync on this channel was this sync obj
|
//check if the last sync on this channel was this sync obj
|
||||||
if (player->hudmap[last_channel] == sync_obj + 1)
|
if (player->hudmap[last_channel] == sync_obj + 1)
|
||||||
{
|
{
|
||||||
//if so, we can safely CLEAR it.
|
//if so, we can safely REUSE it
|
||||||
temp_hud_stuff.a1 = 0;
|
channel = (int)last_channel;
|
||||||
temp_hud_stuff.a2 = 0;
|
|
||||||
temp_hud_stuff.r2 = 255;
|
|
||||||
temp_hud_stuff.g2 = 255;
|
|
||||||
temp_hud_stuff.b2 = 250;
|
|
||||||
temp_hud_stuff.r1 = 0;
|
|
||||||
temp_hud_stuff.g1 = 0;
|
|
||||||
temp_hud_stuff.b1 = 0;
|
|
||||||
temp_hud_stuff.x = 0.0f;
|
|
||||||
temp_hud_stuff.y = 0.0f;
|
|
||||||
temp_hud_stuff.effect = 0;
|
|
||||||
temp_hud_stuff.fxTime = 0.0f;
|
|
||||||
temp_hud_stuff.holdTime = 0.01;
|
|
||||||
temp_hud_stuff.fadeinTime = 0.0f;
|
|
||||||
temp_hud_stuff.fadeoutTime = 0.0f;
|
|
||||||
temp_hud_stuff.channel = last_channel;
|
|
||||||
static char msg[255];
|
|
||||||
msg[0] = '\0';
|
|
||||||
char *msg_ptr = UTIL_SplitHudMessage(msg);
|
|
||||||
UTIL_HudMessage(player->pEdict, temp_hud_stuff, msg_ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//set the new states
|
//set the new states
|
||||||
@ -3945,6 +3925,7 @@ void CheckAndClearPlayerHUD(CPlayer *player, unsigned int channel, unsigned int
|
|||||||
|
|
||||||
static cell AMX_NATIVE_CALL ClearSyncHud(AMX *amx, cell *params)
|
static cell AMX_NATIVE_CALL ClearSyncHud(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
|
int len = 0;
|
||||||
int index = params[1];
|
int index = params[1];
|
||||||
unsigned int sync_obj = static_cast<unsigned int>(params[2]) - 1;
|
unsigned int sync_obj = static_cast<unsigned int>(params[2]) - 1;
|
||||||
|
|
||||||
@ -3954,19 +3935,24 @@ static cell AMX_NATIVE_CALL ClearSyncHud(AMX *amx, cell *params)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cell *plist = g_hudsync[sync_obj];
|
g_langMngr.SetDefLang(params[1]);
|
||||||
|
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
{
|
{
|
||||||
CPlayer *pPlayer;
|
for (int i = 1; i <= gpGlobals->maxClients; ++i)
|
||||||
for (int i = 1; i <= gpGlobals->maxClients; i++)
|
|
||||||
{
|
{
|
||||||
pPlayer = GET_PLAYER_POINTER_I(i);
|
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
||||||
|
|
||||||
if (!pPlayer->ingame)
|
int channel;
|
||||||
continue;
|
if (pPlayer->ingame)
|
||||||
|
{
|
||||||
CheckAndClearPlayerHUD(pPlayer, plist[pPlayer->index], sync_obj);
|
g_langMngr.SetDefLang(i);
|
||||||
|
channel = pPlayer->NextHUDChannel();
|
||||||
|
CheckAndClearPlayerHUD(pPlayer, channel, sync_obj);
|
||||||
|
pPlayer->channels[channel] = gpGlobals->time;
|
||||||
|
g_hudset.channel = channel;
|
||||||
|
UTIL_HudMessage(pPlayer->pEdict, g_hudset, "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (index < 1 || index > gpGlobals->maxClients)
|
if (index < 1 || index > gpGlobals->maxClients)
|
||||||
@ -3974,16 +3960,20 @@ static cell AMX_NATIVE_CALL ClearSyncHud(AMX *amx, cell *params)
|
|||||||
LogError(amx, AMX_ERR_NATIVE, "Invalid player id %d", index);
|
LogError(amx, AMX_ERR_NATIVE, "Invalid player id %d", index);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
|
||||||
|
|
||||||
if (pPlayer->ingame)
|
if (pPlayer->ingame)
|
||||||
{
|
{
|
||||||
CheckAndClearPlayerHUD(pPlayer, plist[pPlayer->index], sync_obj);
|
int channel = pPlayer->NextHUDChannel();
|
||||||
|
CheckAndClearPlayerHUD(pPlayer, channel, sync_obj);
|
||||||
|
pPlayer->channels[channel] = gpGlobals->time;
|
||||||
|
g_hudset.channel = channel;
|
||||||
|
UTIL_HudMessage(pPlayer->pEdict, g_hudset, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
//params[1] - target
|
//params[1] - target
|
||||||
@ -4010,12 +4000,14 @@ static cell AMX_NATIVE_CALL ShowSyncHudMsg(AMX *amx, cell *params)
|
|||||||
{
|
{
|
||||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
|
||||||
|
|
||||||
|
int channel;
|
||||||
if (pPlayer->ingame)
|
if (pPlayer->ingame)
|
||||||
{
|
{
|
||||||
g_langMngr.SetDefLang(i);
|
g_langMngr.SetDefLang(i);
|
||||||
g_hudset.channel = pPlayer->NextHUDChannel();
|
channel = pPlayer->NextHUDChannel();
|
||||||
pPlayer->channels[g_hudset.channel] = gpGlobals->time;
|
CheckAndClearPlayerHUD(pPlayer, channel, sync_obj);
|
||||||
CheckAndClearPlayerHUD(pPlayer, g_hudset.channel, sync_obj);
|
pPlayer->channels[channel] = gpGlobals->time;
|
||||||
|
g_hudset.channel = channel;
|
||||||
message = UTIL_SplitHudMessage(format_amxstring(amx, params, 3, len));
|
message = UTIL_SplitHudMessage(format_amxstring(amx, params, 3, len));
|
||||||
UTIL_HudMessage(pPlayer->pEdict, g_hudset, message);
|
UTIL_HudMessage(pPlayer->pEdict, g_hudset, message);
|
||||||
}
|
}
|
||||||
@ -4031,9 +4023,10 @@ static cell AMX_NATIVE_CALL ShowSyncHudMsg(AMX *amx, cell *params)
|
|||||||
|
|
||||||
if (pPlayer->ingame)
|
if (pPlayer->ingame)
|
||||||
{
|
{
|
||||||
g_hudset.channel = pPlayer->NextHUDChannel();
|
int channel = pPlayer->NextHUDChannel();
|
||||||
pPlayer->channels[g_hudset.channel] = gpGlobals->time;
|
CheckAndClearPlayerHUD(pPlayer, channel, sync_obj);
|
||||||
CheckAndClearPlayerHUD(pPlayer, g_hudset.channel, sync_obj);
|
pPlayer->channels[channel] = gpGlobals->time;
|
||||||
|
g_hudset.channel = channel;
|
||||||
message = UTIL_SplitHudMessage(format_amxstring(amx, params, 3, len));
|
message = UTIL_SplitHudMessage(format_amxstring(amx, params, 3, len));
|
||||||
UTIL_HudMessage(pPlayer->pEdict, g_hudset, message);
|
UTIL_HudMessage(pPlayer->pEdict, g_hudset, message);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user