Make all functions that take a color index receive a color name instead

This commit is contained in:
Lactozilla 2024-04-30 02:01:24 -03:00
parent 93a1aba588
commit 0debddab2c
2 changed files with 124 additions and 171 deletions

View file

@ -299,164 +299,3 @@
#define BOT_2PAI 1
#define BOT_2PHUMAN 2
#define BOT_MPAI 3
// Colors
#define SKINCOLOR_NONE 0
#define SKINCOLOR_WHITE 1
#define SKINCOLOR_BONE 2
#define SKINCOLOR_CLOUDY 3
#define SKINCOLOR_GREY 4
#define SKINCOLOR_SILVER 5
#define SKINCOLOR_CARBON 6
#define SKINCOLOR_JET 7
#define SKINCOLOR_BLACK 8
#define SKINCOLOR_AETHER 9
#define SKINCOLOR_SLATE 10
#define SKINCOLOR_MOONSTONE 11
#define SKINCOLOR_BLUEBELL 12
#define SKINCOLOR_PINK 13
#define SKINCOLOR_ROSEWOOD 14
#define SKINCOLOR_YOGURT 15
#define SKINCOLOR_LATTE 16
#define SKINCOLOR_BROWN 17
#define SKINCOLOR_BOULDER 18
#define SKINCOLOR_BRONZE 19
#define SKINCOLOR_SEPIA 20
#define SKINCOLOR_ECRU 21
#define SKINCOLOR_TAN 22
#define SKINCOLOR_BEIGE 23
#define SKINCOLOR_ROSEBUSH 24
#define SKINCOLOR_MOSS 25
#define SKINCOLOR_AZURE 26
#define SKINCOLOR_EGGPLANT 27
#define SKINCOLOR_LAVENDER 28
#define SKINCOLOR_RUBY 29
#define SKINCOLOR_CHERRY 30
#define SKINCOLOR_SALMON 31
#define SKINCOLOR_PEPPER 32
#define SKINCOLOR_RED 33
#define SKINCOLOR_CRIMSON 34
#define SKINCOLOR_FLAME 35
#define SKINCOLOR_GARNET 36
#define SKINCOLOR_KETCHUP 37
#define SKINCOLOR_PEACHY 38
#define SKINCOLOR_QUAIL 39
#define SKINCOLOR_FOUNDATION 40
#define SKINCOLOR_SUNSET 41
#define SKINCOLOR_COPPER 42
#define SKINCOLOR_APRICOT 43
#define SKINCOLOR_ORANGE 44
#define SKINCOLOR_RUST 45
#define SKINCOLOR_TANGERINE 46
#define SKINCOLOR_TOPAZ 47
#define SKINCOLOR_GOLD 48
#define SKINCOLOR_SANDY 49
#define SKINCOLOR_GOLDENROD 50
#define SKINCOLOR_YELLOW 51
#define SKINCOLOR_OLIVE 52
#define SKINCOLOR_PEAR 53
#define SKINCOLOR_LEMON 54
#define SKINCOLOR_LIME 55
#define SKINCOLOR_PERIDOT 56
#define SKINCOLOR_APPLE 57
#define SKINCOLOR_HEADLIGHT 58
#define SKINCOLOR_CHARTREUSE 59
#define SKINCOLOR_GREEN 60
#define SKINCOLOR_FOREST 61
#define SKINCOLOR_SHAMROCK 62
#define SKINCOLOR_JADE 63
#define SKINCOLOR_MINT 64
#define SKINCOLOR_MASTER 65
#define SKINCOLOR_EMERALD 66
#define SKINCOLOR_SEAFOAM 67
#define SKINCOLOR_ISLAND 68
#define SKINCOLOR_BOTTLE 69
#define SKINCOLOR_AQUA 70
#define SKINCOLOR_TEAL 71
#define SKINCOLOR_OCEAN 72
#define SKINCOLOR_WAVE 73
#define SKINCOLOR_CYAN 74
#define SKINCOLOR_TURQUOISE 75
#define SKINCOLOR_AQUAMARINE 76
#define SKINCOLOR_SKY 77
#define SKINCOLOR_MARINE 78
#define SKINCOLOR_CERULEAN 79
#define SKINCOLOR_DREAM 80
#define SKINCOLOR_ICY 81
#define SKINCOLOR_DAYBREAK 82
#define SKINCOLOR_SAPPHIRE 83
#define SKINCOLOR_ARCTIC 84
#define SKINCOLOR_CORNFLOWER 85
#define SKINCOLOR_BLUE 86
#define SKINCOLOR_COBALT 87
#define SKINCOLOR_MIDNIGHT 88
#define SKINCOLOR_GALAXY 89
#define SKINCOLOR_VAPOR 90
#define SKINCOLOR_DUSK 91
#define SKINCOLOR_MAJESTY 92
#define SKINCOLOR_PASTEL 93
#define SKINCOLOR_PURPLE 94
#define SKINCOLOR_NOBLE 95
#define SKINCOLOR_FUCHSIA 96
#define SKINCOLOR_BUBBLEGUM 97
#define SKINCOLOR_SIBERITE 98
#define SKINCOLOR_MAGENTA 99
#define SKINCOLOR_NEON 100
#define SKINCOLOR_VIOLET 101
#define SKINCOLOR_ROYAL 102
#define SKINCOLOR_LILAC 103
#define SKINCOLOR_MAUVE 104
#define SKINCOLOR_EVENTIDE 105
#define SKINCOLOR_PLUM 106
#define SKINCOLOR_RASPBERRY 107
#define SKINCOLOR_TAFFY 108
#define SKINCOLOR_ROSY 109
#define SKINCOLOR_FANCY 110
#define SKINCOLOR_SANGRIA 111
#define SKINCOLOR_VOLCANIC 112
#define SKINCOLOR_SUPERSILVER1 113
#define SKINCOLOR_SUPERSILVER2 114
#define SKINCOLOR_SUPERSILVER3 115
#define SKINCOLOR_SUPERSILVER4 116
#define SKINCOLOR_SUPERSILVER5 117
#define SKINCOLOR_SUPERRED1 118
#define SKINCOLOR_SUPERRED2 119
#define SKINCOLOR_SUPERRED3 120
#define SKINCOLOR_SUPERRED4 121
#define SKINCOLOR_SUPERRED5 122
#define SKINCOLOR_SUPERORANGE1 123
#define SKINCOLOR_SUPERORANGE2 124
#define SKINCOLOR_SUPERORANGE3 125
#define SKINCOLOR_SUPERORANGE4 126
#define SKINCOLOR_SUPERORANGE5 127
#define SKINCOLOR_SUPERGOLD1 128
#define SKINCOLOR_SUPERGOLD2 129
#define SKINCOLOR_SUPERGOLD3 130
#define SKINCOLOR_SUPERGOLD4 131
#define SKINCOLOR_SUPERGOLD5 132
#define SKINCOLOR_SUPERPERIDOT1 133
#define SKINCOLOR_SUPERPERIDOT2 134
#define SKINCOLOR_SUPERPERIDOT3 135
#define SKINCOLOR_SUPERPERIDOT4 136
#define SKINCOLOR_SUPERPERIDOT5 137
#define SKINCOLOR_SUPERSKY1 138
#define SKINCOLOR_SUPERSKY2 139
#define SKINCOLOR_SUPERSKY3 140
#define SKINCOLOR_SUPERSKY4 141
#define SKINCOLOR_SUPERSKY5 142
#define SKINCOLOR_SUPERPURPLE1 143
#define SKINCOLOR_SUPERPURPLE2 144
#define SKINCOLOR_SUPERPURPLE3 145
#define SKINCOLOR_SUPERPURPLE4 146
#define SKINCOLOR_SUPERPURPLE5 147
#define SKINCOLOR_SUPERRUST1 148
#define SKINCOLOR_SUPERRUST2 149
#define SKINCOLOR_SUPERRUST3 150
#define SKINCOLOR_SUPERRUST4 151
#define SKINCOLOR_SUPERRUST5 152
#define SKINCOLOR_SUPERTAN1 153
#define SKINCOLOR_SUPERTAN2 154
#define SKINCOLOR_SUPERTAN3 155
#define SKINCOLOR_SUPERTAN4 156
#define SKINCOLOR_SUPERTAN5 157

View file

@ -667,6 +667,14 @@ bool CallFunc_ThingCount(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::
return false;
}
}
else
{
CONS_Alert(CONS_WARNING, "ThingCount actor class was not provided.\n");
NO_RETURN(thread);
return false;
}
tid = argV[1];
@ -737,6 +745,8 @@ bool CallFunc_TagWait(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Wor
ACS_TAGTYPE_SECTOR
};
NO_RETURN(thread);
return true; // Execution interrupted
}
@ -756,6 +766,8 @@ bool CallFunc_PolyWait(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Wo
ACS_TAGTYPE_POLYOBJ
};
NO_RETURN(thread);
return true; // Execution interrupted
}
@ -808,6 +820,8 @@ bool CallFunc_ChangeFloor(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM:
sec->floorpic = P_AddLevelFlatRuntime(texName);
}
NO_RETURN(thread);
return false;
}
@ -839,6 +853,8 @@ bool CallFunc_ChangeCeiling(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSV
sec->ceilingpic = P_AddLevelFlatRuntime(texName);
}
NO_RETURN(thread);
return false;
}
@ -878,6 +894,8 @@ bool CallFunc_ClearLineSpecial(ACSVM::Thread *thread, const ACSVM::Word *argV, A
info->line->special = 0;
}
NO_RETURN(thread);
return false;
}
@ -902,6 +920,9 @@ bool CallFunc_EndPrint(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Wo
}
thread->printBuf.drop();
NO_RETURN(thread);
return false;
}
@ -1042,6 +1063,9 @@ bool CallFunc_SectorSound(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM:
}
S_StartSoundAtVolume(origin, sfxId, vol);
NO_RETURN(thread);
return false;
}
@ -1090,6 +1114,9 @@ bool CallFunc_AmbientSound(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM
vol = argV[1];
S_StartSoundAtVolume(NULL, sfxId, vol);
NO_RETURN(thread);
return false;
}
@ -1166,6 +1193,8 @@ bool CallFunc_SetLineTexture(ACSVM::Thread *thread, const ACSVM::Word *argV, ACS
}
}
NO_RETURN(thread);
return false;
}
@ -1207,6 +1236,8 @@ bool CallFunc_SetLineSpecial(ACSVM::Thread *thread, const ACSVM::Word *argV, ACS
}
}
NO_RETURN(thread);
return false;
}
@ -1282,6 +1313,8 @@ bool CallFunc_ThingSound(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::
S_StartSoundAtVolume(mobj, sfxId, vol);
}
NO_RETURN(thread);
return false;
}
@ -1300,6 +1333,9 @@ bool CallFunc_EndPrintBold(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM
HU_DoCEcho(thread->printBuf.data());
thread->printBuf.drop();
NO_RETURN(thread);
return false;
}
/*--------------------------------------------------
@ -1461,6 +1497,9 @@ bool CallFunc_EndLog(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word
CONS_Printf("%s\n", thread->printBuf.data());
thread->printBuf.drop();
NO_RETURN(thread);
return false;
}
@ -3061,12 +3100,44 @@ bool CallFunc_SetObjectDye(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM
auto info = &static_cast<Thread *>(thread)->info;
ACSVM::String *str = thread->scopeMap->getString(argV[1]);
skincolornum_t colorToSet = SKINCOLOR_NONE;
if (str->len > 0)
{
const char *colorName = str->str;
bool success = ACS_GetColorFromString(colorName, &colorToSet);
if (success == false)
{
// Exit early.
CONS_Alert(CONS_WARNING,
"Couldn't find color \"%s\" for SetActorDye.\n",
colorName
);
NO_RETURN(thread);
return false;
}
}
else
{
CONS_Alert(CONS_WARNING, "SetActorDye color was not provided.\n");
NO_RETURN(thread);
return false;
}
mobj_t *mobj = nullptr;
while ((mobj = P_FindMobjFromTID(argV[0], mobj, info->mo)) != nullptr)
{
var1 = 0;
var2 = argV[1];
var2 = colorToSet;
A_Dye(info->mo);
}
@ -3193,7 +3264,7 @@ bool CallFunc_AddBot(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word
ACSVM::String *nameStr = nullptr;
const char *botname = NULL;
UINT16 skincolor = SKINCOLOR_NONE;
skincolornum_t skincolor = SKINCOLOR_NONE;
SINT8 bottype = BOT_MPAI;
@ -3204,7 +3275,26 @@ bool CallFunc_AddBot(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word
// Get skincolor
if (argC >= 2)
skincolor = std::clamp(static_cast<int>(argV[1]), (int)SKINCOLOR_NONE, (int)(MAXSKINCOLORS - 1));
{
ACSVM::String *colorStr = thread->scopeMap->getString(argV[1]);
const char *colorName = colorStr->str;
bool success = ACS_GetColorFromString(colorName, &skincolor);
if (success == false)
{
// Exit early.
CONS_Alert(CONS_WARNING,
"Couldn't find color \"%s\" for AddBot.\n",
colorName
);
NO_RETURN(thread);
return false;
}
}
// Get type
if (argC >= 3)
@ -5547,20 +5637,44 @@ bool CallFunc_OppositeColor(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSV
{
(void)argC;
int color = argV[0];
Environment *env = &ACSEnv;
int result = 0;
ACSVM::String *str = thread->scopeMap->getString(argV[0]);
if (color < 1 || color >= numskincolors)
skincolornum_t invColor = SKINCOLOR_NONE;
if (str->len > 0)
{
CONS_Alert(CONS_WARNING, "OppositeColor color %d out of range (expected 1 - %d).\n", color, numskincolors-1);
skincolornum_t color = SKINCOLOR_NONE;
const char *colorName = str->str;
bool success = ACS_GetColorFromString(colorName, &color);
if (success == false)
{
// Exit early.
CONS_Alert(CONS_WARNING,
"Couldn't find color \"%s\" for OppositeColor.\n",
colorName
);
NO_RETURN(thread);
return false;
}
invColor = static_cast<skincolornum_t>(skincolors[color].invcolor);
}
else
{
result = skincolors[color].invcolor;
}
CONS_Alert(CONS_WARNING, "OppositeColor color was not provided.\n");
thread->dataStk.push(result);
NO_RETURN(thread);
return false;
}
thread->dataStk.push(~env->getString( skincolors[invColor].name )->idx);
return false;
}