Merge pull request #108 from th1000s/vexvoid

Void and Vexing Parse
This commit is contained in:
Louis Gombert 2024-04-20 15:07:09 +00:00 committed by GitHub
commit 72366e1a2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 21 additions and 18 deletions

View File

@ -542,6 +542,9 @@ void FreeHUDItem(int item);
// Updates the customtext2 item, if there is one
void UpdateCustomtext2HUDItem(char *text);
// Returns the item number if there's a customtext2 item, else -1
int FindCustomtext2HUDItem();
// resets hud
void ResetHUD();

View File

@ -2099,7 +2099,6 @@ void msafe_CallFunction(ubyte type, msafe_struct *mstruct) {
break;
}
case MSAFE_MISC_UPDATE_HUD_ITEM:
int FindCustomtext2HUDItem();
// If item not added yet, add it now
if (FindCustomtext2HUDItem() == -1) {
tHUDItem huditem;

View File

@ -2168,7 +2168,7 @@ PInfo *DMFCBase::FindPInfo(int pnum) {
player_record *pr = GetPlayerRecordByPnum(pnum);
if (!pr)
return NULL;
return (PInfo *)pr->pinfo;
return pr->pinfo;
}
// DMFCBase::UpdatePInfo
@ -2226,7 +2226,7 @@ void DMFCBase::ResetPInfo(void) {
for (int i = 0; i < MAX_PLAYER_RECORDS; i++) {
player_record *pr = GetPlayerRecord(i);
if (pr && pr->pinfo) {
((PInfo *)pr->pinfo)->ResetAll();
pr->pinfo->ResetAll();
}
}
}
@ -2344,7 +2344,7 @@ bool DMFCBase::FindPInfoStatFirst(int slot, tPInfoStat *stat) {
if (!pr || pr->state == STATE_EMPTY || !pr->pinfo)
return false;
killer = ((PInfo *)pr->pinfo)->GetFirstKiller();
killer = pr->pinfo->GetFirstKiller();
victim = NULL;
if (!killer) {
@ -2412,7 +2412,7 @@ bool DMFCBase::FindPInfoStatNext(tPInfoStat *stat) {
if (!pr || pr->state == STATE_EMPTY || !pr->pinfo)
return false;
killer = ((PInfo *)pr->pinfo)->GetNextKiller();
killer = pr->pinfo->GetNextKiller();
victim = NULL;
if (!killer) {
@ -2446,7 +2446,7 @@ bool DMFCBase::FindPInfoStatNext(tPInfoStat *stat) {
deaths = 0;
dpr = GetPlayerRecord(killer->slot);
if (dpr && dpr->state != STATE_EMPTY && dpr->pinfo) {
victim = ((PInfo *)dpr->pinfo)->GetKillerInfo(slot);
victim = dpr->pinfo->GetKillerInfo(slot);
}
if (victim)
@ -3379,7 +3379,7 @@ void DMFCBase::CheckPInfo() {
tPKillerInfo *node;
ASSERT(pr->pinfo != NULL);
node = ((PInfo *)pr->pinfo)->GetFirstKiller();
node = pr->pinfo->GetFirstKiller();
while (node) {
ASSERT(node->slot >= 0 && node->slot < 64);

View File

@ -608,7 +608,7 @@ void DMFCBase::OnPlayerEntersObserver(int pnum, object *piggy) {
mprintf((0, "Player %d entering observermode %s\n", pnum, (piggy) ? "Piggyback" : "Roam"));
player_record *pr = PRec_GetPRecordByPnum(pnum);
if (pr && pr->state == STATE_INGAME) {
PInfo *pi = (PInfo *)pr->pinfo;
PInfo *pi = pr->pinfo;
ASSERT(pi != NULL);
pi->EnterObserverMode();
} else {
@ -623,7 +623,7 @@ void DMFCBase::OnPlayerExitsObserver(int pnum) {
mprintf((0, "Player %d leaving observer mode\n", pnum));
player_record *pr = PRec_GetPRecordByPnum(pnum);
if (pr && pr->state == STATE_INGAME) {
PInfo *pi = (PInfo *)pr->pinfo;
PInfo *pi = pr->pinfo;
ASSERT(pi != NULL);
pi->ExitObserverMode();
} else {

View File

@ -295,7 +295,7 @@ int PRec_GetFreeSlot(void) {
// go through all the records and remove this guy as a victim
for (int p = 0; p < MAX_PLAYER_RECORDS; p++) {
if ((p != old_player) && (Player_records[p].pinfo)) {
((PInfo *)Player_records[p].pinfo)->RemoveKiller(old_player);
Player_records[p].pinfo->RemoveKiller(old_player);
}
}
@ -417,7 +417,7 @@ void PRec_LevelReset(void) {
stat->deaths[DSTAT_LEVEL] = 0;
stat->suicides[DSTAT_LEVEL] = 0;
if (Player_records[i].pinfo)
((PInfo *)Player_records[i].pinfo)->ResetAll();
Player_records[i].pinfo->ResetAll();
}
}
@ -488,7 +488,7 @@ void PRec_SendPRecToPlayer(int pnum) {
callsignlen = strlen(Player_records[i].callsign);
if (Player_records[i].pinfo)
pinfo_size = ((PInfo *)Player_records[i].pinfo)->GetSizeOfData();
pinfo_size = Player_records[i].pinfo->GetSizeOfData();
else
pinfo_size = 0;
@ -540,7 +540,7 @@ void PRec_SendPRecToPlayer(int pnum) {
// PInfo stuff
MultiAddInt(pinfo_size, data, &count);
if (pinfo_size > 0) {
((PInfo *)Player_records[i].pinfo)->PackData(&data[count]);
Player_records[i].pinfo->PackData(&data[count]);
count += pinfo_size;
}
@ -610,7 +610,6 @@ void PRec_ReceivePRecFromServer(ubyte *data) {
if (pr->pinfo) {
delete pr->pinfo;
pr->pinfo = NULL;
}
pr->pinfo = new PInfo(slot);
@ -618,11 +617,11 @@ void PRec_ReceivePRecFromServer(ubyte *data) {
pinfo_size = MultiGetInt(data, &count);
if (pinfo_size > 0) {
if (pr->pinfo)
((PInfo *)pr->pinfo)->UnpackData(&data[count], pinfo_size);
pr->pinfo->UnpackData(&data[count], pinfo_size);
count += pinfo_size;
} else {
if (pr->pinfo)
((PInfo *)pr->pinfo)->ResetAll();
pr->pinfo->ResetAll();
}
if (pr->pnum != 255) {

View File

@ -569,6 +569,8 @@ typedef struct {
int kills[2], deaths[2], suicides[2];
} t_dstat;
struct PInfo;
typedef struct {
slot_state state; // state of this slot
char callsign[MAX_CALLSIGN_SIZE]; // Player's callsign
@ -584,8 +586,8 @@ typedef struct {
void *user_info; // Multiplayer Mod user defined struct pointer
int user_info_size; // Size of user_info;
sbyte team; // The player's team (for when they reconnect)
void *pinfo; // Pointer to player info (who killed whom)
sbyte team; // The player's team (for when they reconnect)
PInfo *pinfo; // Pointer to player info (who killed whom)
} player_record;
#define MIF_INCLUDENONE \