mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 04:21:47 +00:00
Fix SOC/Lua loading messages to display full names or even display at all (for PK3s at least), and otherwise some cleanup of existing code for the messages.
Also, I moved lua_lumploading on/offing to LUA_LoadFile.
This commit is contained in:
parent
46704455bb
commit
02862511ae
2 changed files with 34 additions and 17 deletions
|
|
@ -176,11 +176,16 @@ static inline void LUA_LoadFile(MYFILE *f, char *name)
|
||||||
LUA_ClearState();
|
LUA_ClearState();
|
||||||
lua_pushinteger(gL, f->wad);
|
lua_pushinteger(gL, f->wad);
|
||||||
lua_setfield(gL, LUA_REGISTRYINDEX, "WAD");
|
lua_setfield(gL, LUA_REGISTRYINDEX, "WAD");
|
||||||
|
|
||||||
|
lua_lumploading = true; // turn on loading flag
|
||||||
|
|
||||||
if (luaL_loadbuffer(gL, f->data, f->size, va("@%s",name)) || lua_pcall(gL, 0, 0, 0)) {
|
if (luaL_loadbuffer(gL, f->data, f->size, va("@%s",name)) || lua_pcall(gL, 0, 0, 0)) {
|
||||||
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1));
|
CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1));
|
||||||
lua_pop(gL,1);
|
lua_pop(gL,1);
|
||||||
}
|
}
|
||||||
lua_gc(gL, LUA_GCCOLLECT, 0);
|
lua_gc(gL, LUA_GCCOLLECT, 0);
|
||||||
|
|
||||||
|
lua_lumploading = false; // turn off again
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load a script from a lump
|
// Load a script from a lump
|
||||||
|
|
@ -188,24 +193,28 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump)
|
||||||
{
|
{
|
||||||
MYFILE f;
|
MYFILE f;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
f.wad = wad;
|
f.wad = wad;
|
||||||
f.size = W_LumpLengthPwad(wad, lump);
|
f.size = W_LumpLengthPwad(wad, lump);
|
||||||
f.data = Z_Malloc(f.size, PU_LUA, NULL);
|
f.data = Z_Malloc(f.size, PU_LUA, NULL);
|
||||||
W_ReadLumpPwad(wad, lump, f.data);
|
W_ReadLumpPwad(wad, lump, f.data);
|
||||||
f.curpos = f.data;
|
f.curpos = f.data;
|
||||||
|
|
||||||
name = malloc(strlen(wadfiles[wad]->filename)+10);
|
if (wadfiles[wad]->type == RET_LUA)
|
||||||
strcpy(name, wadfiles[wad]->filename);
|
{
|
||||||
if (!fasticmp(&name[strlen(name) - 4], ".lua")) {
|
name = malloc(strlen(wadfiles[wad]->filename)+1);
|
||||||
// If it's not a .lua file, copy the lump name in too.
|
strcpy(name, wadfiles[wad]->filename);
|
||||||
name[strlen(wadfiles[wad]->filename)] = '|';
|
}
|
||||||
M_Memcpy(name+strlen(wadfiles[wad]->filename)+1, wadfiles[wad]->lumpinfo[lump].name, 8);
|
else // If it's not a .lua file, copy the lump name in too.
|
||||||
name[strlen(wadfiles[wad]->filename)+9] = '\0';
|
{
|
||||||
|
lumpinfo_t *lump_p = &wadfiles[wad]->lumpinfo[lump];
|
||||||
|
size_t length = strlen(wadfiles[wad]->filename) + 1 + strlen(lump_p->name2); // length of file name, '|', and lump name
|
||||||
|
name = malloc(length + 1);
|
||||||
|
sprintf(name, "%s|%s", wadfiles[wad]->filename, lump_p->name2);
|
||||||
|
name[length] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_lumploading = true; // turn on loading flag
|
|
||||||
LUA_LoadFile(&f, name); // actually load file!
|
LUA_LoadFile(&f, name); // actually load file!
|
||||||
lua_lumploading = false; // turn off again
|
|
||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
Z_Free(f.data);
|
Z_Free(f.data);
|
||||||
|
|
|
||||||
24
src/w_wad.c
24
src/w_wad.c
|
|
@ -198,7 +198,17 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum)
|
||||||
{
|
{
|
||||||
posEnd = W_CheckNumForFolderEndPK3("SOCs/", wadnum, posStart);
|
posEnd = W_CheckNumForFolderEndPK3("SOCs/", wadnum, posStart);
|
||||||
for(; posStart < posEnd; posStart++)
|
for(; posStart < posEnd; posStart++)
|
||||||
|
{
|
||||||
|
lumpinfo_t *lump_p = &wadfiles[wadnum]->lumpinfo[posStart];
|
||||||
|
size_t length = strlen(wadfiles[wadnum]->filename) + 1 + strlen(lump_p->name2); // length of file name, '|', and lump name
|
||||||
|
char *name = malloc(length + 1);
|
||||||
|
sprintf(name, "%s|%s", wadfiles[wadnum]->filename, lump_p->name2);
|
||||||
|
name[length] = '\0';
|
||||||
|
|
||||||
|
CONS_Printf(M_GetText("Loading SOC from %s\n"), name);
|
||||||
DEH_LoadDehackedLumpPwad(wadnum, posStart);
|
DEH_LoadDehackedLumpPwad(wadnum, posStart);
|
||||||
|
free(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -222,16 +232,14 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum)
|
||||||
for (lump = 0; lump < wadfiles[wadnum]->numlumps; lump++, lump_p++)
|
for (lump = 0; lump < wadfiles[wadnum]->numlumps; lump++, lump_p++)
|
||||||
if (memcmp(lump_p->name,"SOC_",4)==0) // Check for generic SOC lump
|
if (memcmp(lump_p->name,"SOC_",4)==0) // Check for generic SOC lump
|
||||||
{ // shameless copy+paste of code from LUA_LoadLump
|
{ // shameless copy+paste of code from LUA_LoadLump
|
||||||
char *name = malloc(strlen(wadfiles[wadnum]->filename)+10);
|
size_t length = strlen(wadfiles[wadnum]->filename) + 1 + strlen(lump_p->name2); // length of file name, '|', and lump name
|
||||||
strcpy(name, wadfiles[wadnum]->filename);
|
char *name = malloc(length + 1);
|
||||||
/*if (!fasticmp(&name[strlen(name) - 4], ".soc"))*/ {
|
sprintf(name, "%s|%s", wadfiles[wadnum]->filename, lump_p->name2);
|
||||||
// If it's not a .soc file, copy the lump name in too.
|
name[length] = '\0';
|
||||||
name[strlen(wadfiles[wadnum]->filename)] = '|';
|
|
||||||
M_Memcpy(name+strlen(wadfiles[wadnum]->filename)+1, lump_p->name, 8);
|
|
||||||
name[strlen(wadfiles[wadnum]->filename)+9] = '\0';
|
|
||||||
}
|
|
||||||
CONS_Printf(M_GetText("Loading SOC from %s\n"), name);
|
CONS_Printf(M_GetText("Loading SOC from %s\n"), name);
|
||||||
DEH_LoadDehackedLumpPwad(wadnum, lump);
|
DEH_LoadDehackedLumpPwad(wadnum, lump);
|
||||||
|
free(name);
|
||||||
}
|
}
|
||||||
else if (memcmp(lump_p->name,"MAINCFG",8)==0) // Check for MAINCFG
|
else if (memcmp(lump_p->name,"MAINCFG",8)==0) // Check for MAINCFG
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue