From 26d7327b1fb89bf13da9c986e21604cf7e14a6fb Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Tue, 21 May 2019 00:34:42 +0100 Subject: [PATCH] Cleanup (#1200) * Clean up effects.cpp * Clean up monster.cpp * Clean up codec.cpp --- Source/codec.cpp | 3 --- Source/effects.cpp | 7 +------ Source/effects.h | 6 +++--- Source/monster.cpp | 33 ++++++++++++--------------------- structs.h | 2 +- 5 files changed, 17 insertions(+), 34 deletions(-) diff --git a/Source/codec.cpp b/Source/codec.cpp index c72a1304b..a3a02399f 100644 --- a/Source/codec.cpp +++ b/Source/codec.cpp @@ -76,9 +76,6 @@ void codec_init_key(int unused, char *pszPassword) } memset(key, 0, sizeof(key)); } -// 4035DB: using guessed type char var_E0[72]; -// 4035DB: using guessed type char var_58[64]; -// 4035DB: using guessed type char dst[20]; DWORD codec_get_encoded_len(DWORD dwSrcBytes) { diff --git a/Source/effects.cpp b/Source/effects.cpp index 4364d90e4..7b40d9dfb 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1,7 +1,7 @@ #include "diablo.h" #include "../3rdParty/Storm/Source/storm.h" -int sfxdelay; // weak +int sfxdelay; int sfxdnum; HANDLE sfx_stream; TSFX *sfx_data_cur; @@ -971,7 +971,6 @@ void PlayEffect(int i, int mode) snd_play_snd(snd, lVolume, lPan); } -// 676194: using guessed type char gbBufferMsgs; BOOL calc_snd_position(int x, int y, int *plVolume, int *plPan) { @@ -1036,8 +1035,6 @@ void PlaySFX_priv(TSFX *pSFX, BOOL loc, int x, int y) if (pSFX->pSnd) snd_play_snd(pSFX->pSnd, lVolume, lPan); } -// 676194: using guessed type char gbBufferMsgs; -// 679660: using guessed type char gbMaxPlayers; void stream_play(TSFX *pSFX, int lVolume, int lPan) { @@ -1165,7 +1162,6 @@ void effects_update() } } -// 415DBA: could not find valid save-restore pair for ebp void effects_cleanup_sfx() { @@ -1198,7 +1194,6 @@ void stream_update() priv_sound_init(mask); } -// 679660: using guessed type char gbMaxPlayers; void priv_sound_init(UCHAR bLoadMask) { diff --git a/Source/effects.h b/Source/effects.h index ce9f2ad31..20d52c7a9 100644 --- a/Source/effects.h +++ b/Source/effects.h @@ -2,7 +2,7 @@ #ifndef __EFFECTS_H__ #define __EFFECTS_H__ -extern int sfxdelay; // weak +extern int sfxdelay; extern int sfxdnum; extern HANDLE sfx_stream; extern TSFX *sfx_data_cur; @@ -30,8 +30,8 @@ void __stdcall effects_play_sound(char *snd_file); /* rdata */ -extern const int effects_inf; // weak -extern const char monster_action_sounds[]; // idb +extern const int effects_inf; // weak +extern const char monster_action_sounds[]; /* data */ diff --git a/Source/monster.cpp b/Source/monster.cpp index 69268e3dc..55556c31e 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -59,7 +59,6 @@ int rnd5[4] = { 5, 10, 15, 20 }; int rnd10[4] = { 10, 15, 20, 30 }; int rnd20[4] = { 20, 30, 40, 50 }; int rnd60[4] = { 60, 70, 80, 90 }; -// void(*AiProc[])(int i) = { &MAI_Zombie, @@ -99,7 +98,7 @@ void(*AiProc[])(int i) = { void InitMonsterTRN(int monst, BOOL special) { BYTE *f; - int i, n, j, k; + int i, n, j; f = Monsters[monst].trans_file; for (i = 0; i < 256; i++) { @@ -110,13 +109,13 @@ void InitMonsterTRN(int monst, BOOL special) } n = special ? 6 : 5; - for (j = 0; j < n; ++j) { - if (j != 1 || Monsters[monst].mtype < MT_COUNSLR || Monsters[monst].mtype > MT_ADVOCATE) { - for (k = 0; k < 8; k++) { + for (i = 0; i < n; i++) { + if (i != 1 || Monsters[monst].mtype < MT_COUNSLR || Monsters[monst].mtype > MT_ADVOCATE) { + for (j = 0; j < 8; j++) { Cl2ApplyTrans( - Monsters[monst].Anims[j].Data[k], + Monsters[monst].Anims[i].Data[j], Monsters[monst].trans_file, - Monsters[monst].Anims[j].Frames); + Monsters[monst].Anims[i].Frames); } } } @@ -275,7 +274,6 @@ void InitMonsterGFX(int monst) int mtype, anim, i; char strBuff[256]; BYTE *celBuf; - void *trans_file; mtype = Monsters[monst].mtype; @@ -314,11 +312,7 @@ void InitMonsterGFX(int monst) if (monsterdata[mtype].has_trans) { Monsters[monst].trans_file = LoadFileInMem(monsterdata[mtype].TransFile, NULL); InitMonsterTRN(monst, monsterdata[mtype].has_special); - - trans_file = Monsters[monst].trans_file; - Monsters[monst].trans_file = NULL; - - mem_free_dbg(trans_file); + MemFreeDbg(Monsters[monst].trans_file); } if (mtype >= MT_NMAGMA && mtype <= MT_WMAGMA && !(MissileFileFlag & 1)) { @@ -767,7 +761,7 @@ void PlaceUniqueMonst(int uniqindex, int miniontype, int packsize) void PlaceQuestMonsters() { int skeltype; - unsigned char *setp; + BYTE *setp; if (!setlevel) { if (QuestStatus(QTYPE_BUTCH)) { @@ -829,10 +823,8 @@ void PlaceQuestMonsters() SetMapMonsters(setp, 2 * setpc_x, 2 * setpc_y); mem_free_dbg(setp); } - } else { - if (setlvlnum == SL_SKELKING) { - PlaceUniqueMonst(UMT_SKELKING, 0, 0); - } + } else if (setlvlnum == SL_SKELKING) { + PlaceUniqueMonst(UMT_SKELKING, 0, 0); } } @@ -4638,7 +4630,6 @@ void ProcessMonsters() DeleteMonsterList(); } -// 679660: using guessed type char gbMaxPlayers; void FreeMonsters() { @@ -5204,14 +5195,14 @@ BOOL PosOkMonst2(int i, int x, int y) BOOL ret, fire; fire = FALSE; - ret = !SolidLoc(x, y); //12-15 + ret = !SolidLoc(x, y); if (ret && dObject[x][y]) { oi = dObject[x][y] > 0 ? dObject[x][y] - 1 : -(dObject[x][y] + 1); if (object[oi]._oSolidFlag) ret = FALSE; } - if (ret && dMissile[x][y] && i >= 0) { //37 + if (ret && dMissile[x][y] && i >= 0) { mi = dMissile[x][y]; if (mi > 0) { if (missile[mi]._mitype == MIS_FIREWALL) { diff --git a/structs.h b/structs.h index 5c682fbca..bbe3a20a3 100644 --- a/structs.h +++ b/structs.h @@ -534,7 +534,7 @@ typedef struct CMonster { MonsterData *MData; // A TRN file contains a sequence of colour transitions, represented // as indexes into a palette. (a 256 byte array of palette indices) - unsigned char *trans_file; + BYTE *trans_file; } CMonster; typedef struct MonsterStruct { // note: missing field _mAFNum