mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Use PInfo* instead of void*
This avoids a lot of casts back to this (and ever only this) type.
This commit is contained in:
parent
0037e5206e
commit
bd0122e5af
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
@ -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 \
|
||||
|
Loading…
Reference in New Issue
Block a user