Subversion Repositories eduke32

Compare Revisions

Ignore whitespace Rev 8732 → Rev 8734

/source/duke3d/src/gamedef.cpp
28,11 → 28,11
#include "crc32.h"
#include "duke3d.h"
#include "gameexec.h"
#include "gamestructures.h"
#include "kplib.h"
#include "namesdyn.h"
#include "osd.h"
#include "savegame.h"
 
#include "vfs.h"
 
#define LINE_NUMBER (g_lineNumber << 12)
1186,7 → 1186,7
return (isalnum(c) || c == '_' || c == '*' || c == '?' || (i > 0 && (c == '+' || c == '-')));
}
 
static inline int32_t C_GetLabelNameID(const memberlabel_t *pLabel, hashtable_t const * const table, const char *psz)
static inline int32_t C_GetLabelNameID(memberlabel_t const *pLabel, hashtable_t const * const table, const char *psz)
{
// find the label psz in the table pLabel.
// returns the ID for the label, or -1
6305,7 → 6305,7
actorMinMs = 1e308;
 
scriptInitTables();
scriptInitStructTables();
VM_InitHashTables();
 
Gv_Init();
C_InitProjectiles();
/source/duke3d/src/gamedef.h
148,38 → 148,6
 
#if !defined LUNATIC
extern intptr_t *g_scriptPtr;
 
typedef struct
{
const char *name;
 
int32_t lId;
uint32_t flags;
int16_t maxParm2;
int16_t offset;
} memberlabel_t;
 
extern const memberlabel_t ActorLabels[];
extern const memberlabel_t InputLabels[];
extern const memberlabel_t PalDataLabels[];
extern const memberlabel_t PlayerLabels[];
extern const memberlabel_t ProjectileLabels[];
extern const memberlabel_t SectorLabels[];
extern const memberlabel_t TileDataLabels[];
extern const memberlabel_t TsprLabels[];
extern const memberlabel_t UserdefsLabels[];
extern const memberlabel_t WallLabels[];
 
extern hashtable_t h_actor;
extern hashtable_t h_input;
extern hashtable_t h_paldata;
extern hashtable_t h_player;
extern hashtable_t h_projectile;
extern hashtable_t h_sector;
extern hashtable_t h_tiledata;
extern hashtable_t h_tsprite;
extern hashtable_t h_userdef;
extern hashtable_t h_wall;
#endif
 
typedef projectile_t defaultprojectile_t;
/source/duke3d/src/gameexec.cpp
23,14 → 23,15
#include "anim.h"
#include "cmdline.h"
#include "colmatch.h"
#include "communityapi.h"
#include "compat.h"
#include "duke3d.h"
#include "gamestructures.h"
#include "input.h"
#include "menus.h"
#include "osdcmds.h"
#include "savegame.h"
#include "scriplib.h"
#include "communityapi.h"
 
#ifdef LUNATIC
# include "lunatic_game.h"
72,7 → 73,6
 
GAMEEXEC_STATIC void VM_Execute(int const loop = false);
 
# include "gamestructures.cpp"
#endif
 
#if !defined LUNATIC
/source/duke3d/src/gamestructures.cpp
20,30 → 20,14
*/
//-------------------------------------------------------------------------
 
// this is all the crap for accessing the game's structs through the CON VM
// I got a 3-4 fps gain by inlining these...
#include "gamestructures.h"
 
#ifndef gamevars_c_
int32_t __fastcall VM_GetUserdef(int32_t labelNum, int const lParm2);
void __fastcall VM_SetUserdef(int const labelNum, int const lParm2, int32_t const newValue);
int32_t __fastcall VM_GetActiveProjectile(int const spriteNum, int32_t labelNum);
void __fastcall VM_SetActiveProjectile(int const spriteNum, int const labelNum, int32_t const newValue);
int32_t __fastcall VM_GetPlayer(int const playerNum, int32_t labelNum, int const lParm2);
void __fastcall VM_SetPlayer(int const playerNum, int const labelNum, int const lParm2, int32_t const newValue);
int32_t __fastcall VM_GetPlayerInput(int const playerNum, int32_t labelNum);
void __fastcall VM_SetPlayerInput(int const playerNum, int const labelNum, int32_t const newValue);
int32_t __fastcall VM_GetWall(int const wallNum, int32_t labelNum);
void __fastcall VM_SetWall(int const wallNum, int const labelNum, int32_t const newValue);
int32_t __fastcall VM_GetSector(int const sectNum, int32_t labelNum);
void __fastcall VM_SetSector(int const sectNum, int const labelNum, int32_t newValue);
int32_t __fastcall VM_GetSprite(int const spriteNum, int32_t labelNum, int const lParm2);
void __fastcall VM_SetSprite(int const spriteNum, int const labelNum, int const lParm2, int32_t const newValue);
int32_t __fastcall VM_GetProjectile(int const tileNum, int32_t labelNum);
void __fastcall VM_SetProjectile(int const tileNum, int const labelNum, int32_t const newValue);
int32_t __fastcall VM_GetTileData(int const tileNum, int32_t labelNum);
void __fastcall VM_SetTileData(int const tileNum, int const labelNum, int32_t const newValue);
int32_t __fastcall VM_GetPalData(int const palNum, int32_t labelNum);
#else
#include "compat.h"
#include "gamedef.h"
#include "sector.h"
#include "gameexec.h"
#include "global.h"
 
#define LABEL_SETUP_UNMATCHED(struct, memb, name, idx) \
{ \
name, idx, sizeof(struct[0].memb) | (is_unsigned<decltype(struct[0].memb)>::value ? LABEL_UNSIGNED : 0), 0, \
52,7 → 36,7
 
#define LABEL_SETUP(struct, memb, idx) LABEL_SETUP_UNMATCHED(struct, memb, #memb, idx)
 
const memberlabel_t SectorLabels[] = {
memberlabel_t const SectorLabels[] = {
{ "wallptr", SECTOR_WALLPTR, sizeof(sector[0].wallptr) | LABEL_WRITEFUNC, 0, offsetof(usectortype, wallptr) },
LABEL_SETUP(sector, wallnum, SECTOR_WALLNUM),
 
176,7 → 160,7
}
}
 
const memberlabel_t WallLabels[]=
memberlabel_t const WallLabels[]=
{
LABEL_SETUP(wall, x, WALL_X),
LABEL_SETUP(wall, y, WALL_Y),
247,7 → 231,7
 
}
 
const memberlabel_t ActorLabels[]=
memberlabel_t const ActorLabels[]=
{
LABEL_SETUP(sprite, x, ACTOR_X),
LABEL_SETUP(sprite, y, ACTOR_Y),
357,7 → 341,7
return labelNum;
}
 
const memberlabel_t TsprLabels[] =
memberlabel_t const TsprLabels[] =
{
// tsprite access
 
386,7 → 370,7
LABEL_SETUP_UNMATCHED(sprite, extra, "tsprextra", ACTOR_EXTRA),
};
 
const memberlabel_t PlayerLabels[]=
memberlabel_t const PlayerLabels[]=
{
{ "zoom", PLAYER_ZOOM, 0, 0, -1 },
{ "loogiex", PLAYER_LOOGIEX, LABEL_HASPARM2, 64, -1 },
961,7 → 945,7
}
}
 
const memberlabel_t ProjectileLabels[]=
memberlabel_t const ProjectileLabels[]=
{
{ "workslike", PROJ_WORKSLIKE, 0, 0, -1 },
{ "spawns", PROJ_SPAWNS, 0, 0, -1 },
1183,7 → 1167,7
}
}
 
const memberlabel_t UserdefsLabels[]=
memberlabel_t const UserdefsLabels[]=
{
{ "god", USERDEFS_GOD, 0, 0, -1 },
{ "warp_on", USERDEFS_WARP_ON, 0, 0, -1 },
1773,7 → 1757,7
}
}
 
const memberlabel_t InputLabels[]=
memberlabel_t const InputLabels[]=
{
{ "avel", INPUT_AVEL, 0, 0, -1 },
{ "q16avel", INPUT_Q16AVEL, 0, 0, -1 },
1843,7 → 1827,7
}
}
 
const memberlabel_t TileDataLabels[]=
memberlabel_t const TileDataLabels[]=
{
// tilesiz[]
{ "xsize", TILEDATA_XSIZE, 0, 0, -1 },
1916,7 → 1900,7
}
}
 
const memberlabel_t PalDataLabels[]=
memberlabel_t const PalDataLabels[]=
{
// g_noFloorPal[]
{ "nofloorpal", PALDATA_NOFLOORPAL, 0, 0, -1 },
1952,10 → 1936,6
hashtable_t h_userdef = { USERDEFS_END>>1, NULL };
hashtable_t h_wall = { WALL_END>>1, NULL };
 
static hashtable_t *const struct_tables[] = {
&h_actor, &h_input, &h_paldata, &h_player, &h_projectile, &h_sector, &h_tiledata, &h_tsprite, &h_userdef, &h_wall,
};
 
#define STRUCT_HASH_SETUP(table, labels) \
do \
{ \
1964,9 → 1944,9
EDUKE32_STATIC_ASSERT(ARRAY_SSIZE(labels) != 0); \
} while (0)
 
void scriptInitStructTables(void)
void VM_InitHashTables(void)
{
for (auto table : struct_tables)
for (auto table : vmStructHashTablePtrs)
hash_init(table);
 
inithashnames();
1985,4 → 1965,3
}
#undef STRUCT_HASH_SETUP
 
#endif
/source/duke3d/src/gamestructures.h
0,0 → 1,94
//-------------------------------------------------------------------------
/*
Copyright (C) 2004-2020 EDuke32 developers and contributors
 
This file is part of EDuke32.
 
EDuke32 is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
See the GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
 
#pragma once
#ifndef gamestructures_h__
#define gamestructures_h__
 
#include "compat.h"
#include "hash.h"
 
#ifdef __cplusplus
extern "C" {
#endif
 
int32_t __fastcall VM_GetUserdef(int32_t labelNum, int const lParm2);
void __fastcall VM_SetUserdef(int const labelNum, int const lParm2, int32_t const newValue);
int32_t __fastcall VM_GetActiveProjectile(int const spriteNum, int32_t labelNum);
void __fastcall VM_SetActiveProjectile(int const spriteNum, int const labelNum, int32_t const newValue);
int32_t __fastcall VM_GetPlayer(int const playerNum, int32_t labelNum, int const lParm2);
void __fastcall VM_SetPlayer(int const playerNum, int const labelNum, int const lParm2, int32_t const newValue);
int32_t __fastcall VM_GetPlayerInput(int const playerNum, int32_t labelNum);
void __fastcall VM_SetPlayerInput(int const playerNum, int const labelNum, int32_t const newValue);
int32_t __fastcall VM_GetWall(int const wallNum, int32_t labelNum);
void __fastcall VM_SetWall(int const wallNum, int const labelNum, int32_t const newValue);
int32_t __fastcall VM_GetSector(int const sectNum, int32_t labelNum);
void __fastcall VM_SetSector(int const sectNum, int const labelNum, int32_t newValue);
int32_t __fastcall VM_GetSprite(int const spriteNum, int32_t labelNum, int const lParm2);
void __fastcall VM_SetSprite(int const spriteNum, int const labelNum, int const lParm2, int32_t const newValue);
int32_t __fastcall VM_GetProjectile(int const tileNum, int32_t labelNum);
void __fastcall VM_SetProjectile(int const tileNum, int const labelNum, int32_t const newValue);
int32_t __fastcall VM_GetTileData(int const tileNum, int32_t labelNum);
void __fastcall VM_SetTileData(int const tileNum, int const labelNum, int32_t const newValue);
int32_t __fastcall VM_GetPalData(int const palNum, int32_t labelNum);
 
typedef struct
{
const char *name;
 
int32_t lId;
uint32_t flags;
int16_t maxParm2;
int16_t offset;
} memberlabel_t;
 
extern memberlabel_t const ActorLabels[];
extern memberlabel_t const InputLabels[];
extern memberlabel_t const PalDataLabels[];
extern memberlabel_t const PlayerLabels[];
extern memberlabel_t const ProjectileLabels[];
extern memberlabel_t const SectorLabels[];
extern memberlabel_t const TileDataLabels[];
extern memberlabel_t const TsprLabels[];
extern memberlabel_t const UserdefsLabels[];
extern memberlabel_t const WallLabels[];
 
extern hashtable_t h_actor;
extern hashtable_t h_input;
extern hashtable_t h_paldata;
extern hashtable_t h_player;
extern hashtable_t h_projectile;
extern hashtable_t h_sector;
extern hashtable_t h_tiledata;
extern hashtable_t h_tsprite;
extern hashtable_t h_userdef;
extern hashtable_t h_wall;
 
static hashtable_t *const vmStructHashTablePtrs[] = {
&h_actor, &h_input, &h_paldata, &h_player, &h_projectile, &h_sector, &h_tiledata, &h_tsprite, &h_userdef, &h_wall,
};
 
#ifdef __cplusplus
}
#endif
 
#endif // gamestructures_h__
/source/duke3d/src/gamevars.cpp
25,9 → 25,8
#include "savegame.h"
 
#include "vfs.h"
#include "gamestructures.h"
 
#define gamevars_c_
 
#ifdef LUNATIC
int32_t g_noResetVars;
LUNATIC_CB void (*A_ResetVars)(int32_t spriteNum);
59,8 → 58,6
intptr_t *aplWeaponTotalTime[MAX_WEAPONS]; // The total time the weapon is cycling before next fire.
intptr_t *aplWeaponWorksLike[MAX_WEAPONS]; // What original the weapon works like
 
# include "gamestructures.cpp"
 
// Frees the memory for the *values* of game variables and arrays. Resets their
// counts to zero. Call this function as many times as needed.
//
105,7 → 102,7
for (auto & gameArray : aGameArrays)
DO_FREE_AND_NULL(gameArray.szLabel);
 
for (auto i : struct_tables)
for (auto i : vmStructHashTablePtrs)
hash_free(i);
}
 
/source/duke3d/src/gamevars.h
149,7 → 149,7
gv.pValues[spriteNum] = gv.defaultValue;
}
}
void scriptInitStructTables(void);
void VM_InitHashTables(void);
void Gv_DumpValues(void);
void Gv_InitWeaponPointers(void);
void Gv_RefreshPointers(void);
/source/duke3d/src/m32def.cpp
448,7 → 448,7
"<null>"
};
 
const memberlabel_t SectorLabels[]=
memberlabel_t const SectorLabels[]=
{
{ "wallptr", SECTOR_WALLPTR, 1, 0, 0 },
{ "wallnum", SECTOR_WALLNUM, 1, 0, 0 },
481,7 → 481,7
{ "", -1, 0, 0, 0 } // END OF LIST
};
 
const memberlabel_t WallLabels[]=
memberlabel_t const WallLabels[]=
{
{ "x", WALL_X, 0, -BXY_MAX, BXY_MAX },
{ "y", WALL_Y, 0, -BXY_MAX, BXY_MAX },
503,7 → 503,7
{ "", -1, 0, 0, 0 } // END OF LIST
};
 
const memberlabel_t SpriteLabels[]=
memberlabel_t const SpriteLabels[]=
{
{ "x", SPRITE_X, 0, -BXY_MAX, BXY_MAX },
{ "y", SPRITE_Y, 0, -BXY_MAX, BXY_MAX },
535,7 → 535,7
# define PR_MAXLIGHTPRIORITY 6
#endif
 
const memberlabel_t LightLabels[]=
memberlabel_t const LightLabels[]=
{
{ "x", LIGHT_X, 0, -BXY_MAX, BXY_MAX },
{ "y", LIGHT_Y, 0, -BXY_MAX, BXY_MAX },
736,7 → 736,7
return 0;
}
 
static inline int32_t C_GetLabelNameID(const memberlabel_t *pLabel, hashtable_t *tH, const char *psz)
static inline int32_t C_GetLabelNameID(memberlabel_t const *pLabel, hashtable_t *tH, const char *psz)
{
// find the label psz in the table pLabel.
// returns the ID for the label, or -1
/source/duke3d/src/m32def.h
79,10 → 79,10
int32_t min, max;
} memberlabel_t;
 
extern const memberlabel_t SectorLabels[];
extern const memberlabel_t WallLabels[];
extern const memberlabel_t SpriteLabels[];
extern const memberlabel_t LightLabels[];
extern memberlabel_t const SectorLabels[];
extern memberlabel_t const WallLabels[];
extern memberlabel_t const SpriteLabels[];
extern memberlabel_t const LightLabels[];
 
 
typedef struct {
/source/duke3d/src/m32exec.cpp
2453,7 → 2453,7
{
int32_t memberid=(code>>2)&63, lightp = (memberid >= LIGHT_X);
const char *pp1[4] = {"sprite","sector","wall","tsprite"};
const memberlabel_t *pp2[4] = {SpriteLabels, SectorLabels, WallLabels, SpriteLabels};
memberlabel_t const *pp2[4] = {SpriteLabels, SectorLabels, WallLabels, SpriteLabels};
if (lightp)
{
pp1[3] = "light";
/source/duke3d/src/m32structures.cpp
387,7 → 387,7
int32_t lightp = (labelNum >= LIGHT_X);
int32_t i = (how&ACCESS_USEVARS) ? vm.spriteNum : lVar1;
tspriteptr_t datspr = nullptr;
const memberlabel_t *dalabel = lightp ? &LightLabels[labelNum-LIGHT_X] : &SpriteLabels[labelNum];
memberlabel_t const *dalabel = lightp ? &LightLabels[labelNum-LIGHT_X] : &SpriteLabels[labelNum];
 
if ((how&ACCESS_USEVARS) && lVar1 != M32_THISACTOR_VAR_ID)
i = Gv_GetVar(lVar1);