mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
C-CON: Implement tilesizx/y gamearrays in a fashion similar to M32Script's solution: a STRIDE2 flag.
git-svn-id: https://svn.eduke32.com/eduke32@5090 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
a14109da20
commit
bd0f05a706
3 changed files with 51 additions and 33 deletions
|
@ -3911,7 +3911,7 @@ finish_qsprintf:
|
|||
{
|
||||
OSD_Printf(OSDTEXT_GREEN "%s: L=%d %s[%d] =%d\n", keyw[g_tw], g_errorLineNum,
|
||||
aGameArrays[lVarID].szLabel, index,
|
||||
(int32_t)(m*aGameArrays[lVarID].plValues[index]));
|
||||
(int32_t)(m*Gv_GetGameArrayValue(lVarID, index)));
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
@ -4631,16 +4631,10 @@ finish_qsprintf:
|
|||
}
|
||||
|
||||
const int32_t n = aGameArrays[j].size;
|
||||
#ifdef BITNESS64
|
||||
int32_t *const array = (int32_t *)Xmalloc(sizeof(int32_t) * n);
|
||||
for (int32_t k = 0; k < n; k++) array[k] = aGameArrays[j].plValues[k];
|
||||
#else
|
||||
int32_t *const array = (int32_t *)aGameArrays[j].plValues;
|
||||
#endif
|
||||
for (int32_t k = 0; k < n; k++) array[k] = Gv_GetGameArrayValue(j, k);
|
||||
fwrite(array, 1, sizeof(int32_t) * n, fil);
|
||||
#ifdef BITNESS64
|
||||
Bfree(array);
|
||||
#endif
|
||||
fclose(fil);
|
||||
|
||||
continue;
|
||||
|
@ -4715,22 +4709,46 @@ finish_qsprintf:
|
|||
{
|
||||
case 0:
|
||||
// CON array to CON array.
|
||||
if (EDUKE32_PREDICT_FALSE(aGameArrays[si].dwFlags & GAMEARRAY_STRIDE2))
|
||||
{
|
||||
for (; numelts>0; --numelts)
|
||||
(aGameArrays[di].plValues)[didx++] = ((int32_t *)aGameArrays[si].plValues)[sidx+=2];
|
||||
break;
|
||||
}
|
||||
Bmemcpy(aGameArrays[di].plValues+didx, aGameArrays[si].plValues+sidx, numelts*GAR_ELTSZ);
|
||||
break;
|
||||
case GAMEARRAY_OFINT:
|
||||
// From int32-sized array. Note that the CON array element
|
||||
// type is intptr_t, so it is different-sized on 64-bit
|
||||
// archs, but same-sized on 32-bit ones.
|
||||
if (EDUKE32_PREDICT_FALSE(aGameArrays[si].dwFlags & GAMEARRAY_STRIDE2))
|
||||
{
|
||||
for (; numelts>0; --numelts)
|
||||
(aGameArrays[di].plValues)[didx++] = ((int32_t *)aGameArrays[si].plValues)[sidx+=2];
|
||||
break;
|
||||
}
|
||||
for (; numelts>0; --numelts)
|
||||
(aGameArrays[di].plValues)[didx++] = ((int32_t *)aGameArrays[si].plValues)[sidx++];
|
||||
break;
|
||||
case GAMEARRAY_OFSHORT:
|
||||
// From int16_t array. Always different-sized.
|
||||
if (EDUKE32_PREDICT_FALSE(aGameArrays[si].dwFlags & GAMEARRAY_STRIDE2))
|
||||
{
|
||||
for (; numelts>0; --numelts)
|
||||
(aGameArrays[di].plValues)[didx++] = ((int16_t *)aGameArrays[si].plValues)[sidx+=2];
|
||||
break;
|
||||
}
|
||||
for (; numelts>0; --numelts)
|
||||
(aGameArrays[di].plValues)[didx++] = ((int16_t *)aGameArrays[si].plValues)[sidx++];
|
||||
break;
|
||||
case GAMEARRAY_OFCHAR:
|
||||
// From char array. Always different-sized.
|
||||
if (EDUKE32_PREDICT_FALSE(aGameArrays[si].dwFlags & GAMEARRAY_STRIDE2))
|
||||
{
|
||||
for (; numelts>0; --numelts)
|
||||
(aGameArrays[di].plValues)[didx++] = ((uint8_t *)aGameArrays[si].plValues)[sidx+=2];
|
||||
break;
|
||||
}
|
||||
for (; numelts>0; --numelts)
|
||||
(aGameArrays[di].plValues)[didx++] = ((uint8_t *)aGameArrays[si].plValues)[sidx++];
|
||||
break;
|
||||
|
|
|
@ -594,6 +594,24 @@ static int32_t Gv_GetVarIndex(const char *szGameLabel)
|
|||
return i;
|
||||
}
|
||||
|
||||
int32_t __fastcall Gv_GetGameArrayValue(register int32_t const id, register int32_t index)
|
||||
{
|
||||
int rv = -1;
|
||||
|
||||
if (aGameArrays[id].dwFlags & GAMEARRAY_STRIDE2)
|
||||
index <<= 1;
|
||||
|
||||
switch (aGameArrays[id].dwFlags & GAMEARRAY_TYPE_MASK)
|
||||
{
|
||||
case 0: rv = (aGameArrays[id].plValues)[index]; break;
|
||||
case GAMEARRAY_OFINT: rv = ((int32_t *) aGameArrays[id].plValues)[index]; break;
|
||||
case GAMEARRAY_OFSHORT: rv = ((int16_t *) aGameArrays[id].plValues)[index]; break;
|
||||
case GAMEARRAY_OFCHAR: rv = ((uint8_t *) aGameArrays[id].plValues)[index]; break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int32_t __fastcall Gv_GetVar(int32_t id, int32_t iActor, int32_t iPlayer)
|
||||
{
|
||||
if (id == g_iThisActorID)
|
||||
|
@ -646,7 +664,7 @@ nastyhacks:
|
|||
goto badindex;
|
||||
}
|
||||
|
||||
rv = aGameArrays[id].plValues[index];
|
||||
rv = Gv_GetGameArrayValue(id, index);
|
||||
}
|
||||
else if (id&(MAXGAMEVARS<<3)) // struct shortcut vars
|
||||
{
|
||||
|
@ -892,13 +910,7 @@ int32_t __fastcall Gv_GetSpecialVarX(int32_t id)
|
|||
return -1;
|
||||
}
|
||||
|
||||
switch (aGameArrays[id].dwFlags & GAMEARRAY_TYPE_MASK)
|
||||
{
|
||||
case 0: rv = (aGameArrays[id].plValues)[index]; break;
|
||||
case GAMEARRAY_OFINT: rv = ((int32_t *) aGameArrays[id].plValues)[index]; break;
|
||||
case GAMEARRAY_OFSHORT: rv = ((int16_t *) aGameArrays[id].plValues)[index]; break;
|
||||
case GAMEARRAY_OFCHAR: rv = ((uint8_t *) aGameArrays[id].plValues)[index]; break;
|
||||
}
|
||||
rv = Gv_GetGameArrayValue(id, index);
|
||||
}
|
||||
else if (id & (MAXGAMEVARS << 3)) // struct shortcut vars
|
||||
{
|
||||
|
@ -1276,23 +1288,6 @@ void Gv_ResetSystemDefaults(void)
|
|||
if (g_tile[i].defproj)
|
||||
*g_tile[i].proj = *g_tile[i].defproj;
|
||||
|
||||
#ifndef LUNATIC
|
||||
int i;
|
||||
|
||||
// hackhackhackhackhack
|
||||
if (i = hash_find(&h_arrays, "tilesizx"), i >= 0)
|
||||
{
|
||||
for (int j = 0; j < MAXTILES; j++)
|
||||
aGameArrays[i].plValues[j] = tilesiz[j].x;
|
||||
}
|
||||
|
||||
if (i = hash_find(&h_arrays, "tilesizy"), i >= 0)
|
||||
{
|
||||
for (int j = 0; j < MAXTILES; j++)
|
||||
aGameArrays[i].plValues[j] = tilesiz[j].y;
|
||||
}
|
||||
#endif
|
||||
|
||||
//AddLog("EOF:ResetWeaponDefaults");
|
||||
}
|
||||
|
||||
|
@ -1682,6 +1677,8 @@ static void Gv_AddSystemVars(void)
|
|||
# endif
|
||||
|
||||
// SYSTEM_GAMEARRAY
|
||||
Gv_NewArray("tilesizx", (void *)&tilesiz[0].x, MAXTILES, GAMEARRAY_STRIDE2|GAMEARRAY_READONLY|GAMEARRAY_OFINT);
|
||||
Gv_NewArray("tilesizy", (void *)&tilesiz[0].y, MAXTILES, GAMEARRAY_STRIDE2|GAMEARRAY_READONLY|GAMEARRAY_OFINT);
|
||||
Gv_NewArray("tilesizx", NULL, MAXTILES, GAMEARRAY_READONLY);
|
||||
Gv_NewArray("tilesizy", NULL, MAXTILES, GAMEARRAY_READONLY);
|
||||
#endif
|
||||
|
|
|
@ -70,6 +70,8 @@ enum GamearrayFlags_t {
|
|||
|
||||
GAMEARRAY_VARSIZE = 0x00000020,
|
||||
|
||||
GAMEARRAY_STRIDE2 = 0x00000100,
|
||||
|
||||
GAMEARRAY_RESET = 0x00000008,
|
||||
/// GAMEARRAY_NORESET = 0x00000001,
|
||||
};
|
||||
|
@ -100,6 +102,7 @@ extern gamearray_t aGameArrays[MAXGAMEARRAYS];
|
|||
extern int32_t g_gameVarCount;
|
||||
extern int32_t g_gameArrayCount;
|
||||
|
||||
int32_t __fastcall Gv_GetGameArrayValue(register int32_t const id, register int32_t index);
|
||||
int32_t __fastcall Gv_GetVar(int32_t id, int32_t iActor, int32_t iPlayer);
|
||||
void __fastcall Gv_SetVar(int32_t const id, int32_t const lValue, int32_t const iActor, int32_t const iPlayer);
|
||||
int32_t __fastcall Gv_GetVarX(int32_t id);
|
||||
|
|
Loading…
Reference in a new issue