From cab3ebddf5a9d4a5981eb0353377458adea2c4a0 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Mon, 6 Apr 2020 02:39:48 +0200 Subject: [PATCH] Avoid some arrays being of predefined size This makes it easier to change the array size via content --- Source/control.cpp | 4 +- Source/spelldat.cpp | 2 +- Source/spelldat.h | 2 +- Source/trigs.cpp | 92 +++++++-------------------------------------- 4 files changed, 18 insertions(+), 82 deletions(-) diff --git a/Source/control.cpp b/Source/control.cpp index d5c9f37d5..433c20014 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -35,7 +35,7 @@ BOOL talkbtndown[3]; int pSpell; BYTE *pManaBuff; char infoclr; -int sgbPlrTalkTbl; // should be char [4] +int sgbPlrTalkTbl; BYTE *pGBoxBuff; BYTE *pSBkBtnCel; char tempstr[256]; @@ -152,7 +152,7 @@ const BYTE gbFontTransTbl[256] = { 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'X', '0', 'U', 'U', 'U', 'U', 'Y', 'b', 'B', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', - 'o', 'n', 'o', 'o', 'o', 'o', 'o', '/', '0', 'u', 'u', 'u', 'u', 'y', 'b', 'y' + 'o', 'n', 'o', 'o', 'o', 'o', 'o', '/', '0', 'u', 'u', 'u', 'u', 'y', 'b', 'y', // clang-format on }; diff --git a/Source/spelldat.cpp b/Source/spelldat.cpp index ce198eaf6..c7bcd4415 100644 --- a/Source/spelldat.cpp +++ b/Source/spelldat.cpp @@ -1,7 +1,7 @@ #include "all.h" /** Data related to each spell ID. */ -SpellData spelldata[MAX_SPELLS] = { +SpellData spelldata[] = { // clang-format off // sName, sManaCost, sType, sNameText, sSkillText, sBookLvl, sStaffLvl, sTargeted, sTownSpell, sMinInt, sSFX, sMissiles[3], sManaAdj, sMinMana, sStaffMin, sStaffMax, sBookCost, sStaffCost { SPL_NULL, 0, 0, NULL, NULL, 0, 0, FALSE, FALSE, 0, 0, { 0, 0, 0 }, 0, 0, 40, 80, 0, 0 }, diff --git a/Source/spelldat.h b/Source/spelldat.h index adb185c72..2c894f3b9 100644 --- a/Source/spelldat.h +++ b/Source/spelldat.h @@ -2,6 +2,6 @@ #ifndef __SPELLDAT_H__ #define __SPELLDAT_H__ -extern SpellData spelldata[MAX_SPELLS]; +extern SpellData spelldata[]; #endif /* __SPELLDAT_H__ */ diff --git a/Source/trigs.cpp b/Source/trigs.cpp index c005a371d..240154b42 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -6,84 +6,20 @@ int numtrigs; TriggerStruct trigs[MAXTRIGGERS]; int TWarpFrom; -int TownDownList[11] = { 716, 715, 719, 720, 721, 723, 724, 725, 726, 727, -1 }; -int TownWarp1List[13] = { - 1171, - 1172, - 1173, - 1174, - 1175, - 1176, - 1177, - 1178, - 1179, - 1181, - 1183, - 1185, - -1 -}; -int L1UpList[12] = { 127, 129, 130, 131, 132, 133, 135, 137, 138, 139, 140, -1 }; -int L1DownList[10] = { 106, 107, 108, 109, 110, 112, 114, 115, 118, -1 }; -int L2UpList[3] = { 266, 267, -1 }; -int L2DownList[5] = { 269, 270, 271, 272, -1 }; -int L2TWarpUpList[3] = { 558, 559, -1 }; -int L3UpList[15] = { - 170, - 171, - 172, - 173, - 174, - 175, - 176, - 177, - 178, - 179, - 180, - 181, - 182, - 183, - -1 -}; -int L3DownList[9] = { 162, 163, 164, 165, 166, 167, 168, 169, -1 }; -int L3TWarpUpList[14] = { 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, -1 }; -int L4UpList[4] = { 82, 83, 90, -1 }; -int L4DownList[6] = { 120, 130, 131, 132, 133, -1 }; -int L4TWarpUpList[4] = { 421, 422, 429, -1 }; -int L4PentaList[33] = { - 353, - 354, - 355, - 356, - 357, - 358, - 359, - 360, - 361, - 362, - 363, - 364, - 365, - 366, - 367, - 368, - 369, - 370, - 371, - 372, - 373, - 374, - 375, - 376, - 377, - 378, - 379, - 380, - 381, - 382, - 383, - 384, - -1 -}; +int TownDownList[] = { 716, 715, 719, 720, 721, 723, 724, 725, 726, 727, -1 }; +int TownWarp1List[] = { 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1181, 1183, 1185, -1 }; +int L1UpList[] = { 127, 129, 130, 131, 132, 133, 135, 137, 138, 139, 140, -1 }; +int L1DownList[] = { 106, 107, 108, 109, 110, 112, 114, 115, 118, -1 }; +int L2UpList[] = { 266, 267, -1 }; +int L2DownList[] = { 269, 270, 271, 272, -1 }; +int L2TWarpUpList[] = { 558, 559, -1 }; +int L3UpList[] = { 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, -1 }; +int L3DownList[] = { 162, 163, 164, 165, 166, 167, 168, 169, -1 }; +int L3TWarpUpList[] = { 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, -1 }; +int L4UpList[] = { 82, 83, 90, -1 }; +int L4DownList[] = { 120, 130, 131, 132, 133, -1 }; +int L4TWarpUpList[] = { 421, 422, 429, -1 }; +int L4PentaList[] = { 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, -1 }; #ifndef SPAWN void InitNoTriggers()