diff --git a/polymer-perf/eduke32/Makefile b/polymer-perf/eduke32/Makefile index 6d4946aa5..58df36edf 100644 --- a/polymer-perf/eduke32/Makefile +++ b/polymer-perf/eduke32/Makefile @@ -224,7 +224,7 @@ ifeq ($(PRETTY_OUTPUT),1) endif $(MAKE) -C $(EROOT)/ "OBJ=../$(EOBJ)" $@ #\ - SUPERBUILD=$(SUPERBUILD) POLYMOST=$(POLYMOST) DEBUGANYWAY=$(DEBUGANYWAY) KRANDDEBUG=$(KRANDDEBUG)\ + DEBUGANYWAY=$(DEBUGANYWAY) KRANDDEBUG=$(KRANDDEBUG)\ USE_OPENGL=$(USE_OPENGL) BUILD32_ON_64=$(BUILD32_ON_64) PROFILER=$(PROFILER)\ NOASM=$(NOASM) NEDMALLOC=$(NEDMALLOC) RELEASE=$(RELEASE) OPTLEVEL=$(OPTLEVEL) $@ ifeq ($(PRETTY_OUTPUT),1) diff --git a/polymer-perf/eduke32/Makefile.common b/polymer-perf/eduke32/Makefile.common index 5d502a898..02f636251 100644 --- a/polymer-perf/eduke32/Makefile.common +++ b/polymer-perf/eduke32/Makefile.common @@ -11,14 +11,11 @@ PRETTY_OUTPUT ?= 1 DXROOT_OVERRIDE:= # Engine options -# SUPERBUILD - enables voxels -# POLYMOST - enables Polymost renderer -# USE_OPENGL - enables OpenGL support in Polymost +# USE_OPENGL - enables basic OpenGL Polymost renderer +# POLYMER - enables fancy Polymer renderer # NOASM - disables the use of inline assembly pragmas # LINKED_GTK - enables compile-time linkage to GTK # -SUPERBUILD = 1 -POLYMOST = 1 POLYMER = 1 USE_OPENGL = 1 NOASM = 0 @@ -27,7 +24,6 @@ BUILD32_ON_64 = 0 NEDMALLOC = 1 ifeq (0,$(USE_OPENGL)) - POLYMOST = 0 POLYMER = 0 endif diff --git a/polymer-perf/eduke32/Makefile.msvc b/polymer-perf/eduke32/Makefile.msvc index 02a4afba7..36d15829a 100644 --- a/polymer-perf/eduke32/Makefile.msvc +++ b/polymer-perf/eduke32/Makefile.msvc @@ -20,8 +20,8 @@ EDITORLIB=build.lib # the WDK allows us to link against msvcrt.dll instead of msvcrxxx.dll # this path should match build\Makefile.msvc -WDKROOT="C:\WinDDK\7600.16385.1" -DXROOT="C:\Program Files\Microsoft DirectX SDK (February 2010)" +WDKROOT="H:\WinDDK\7600.16385.1" +DXROOT="H:\Microsoft DirectX SDK (February 2010)" !ifdef DEBUG # debugging options @@ -33,7 +33,7 @@ flags_cl=/O2 /GL /arch:SSE /MP /I$(WDKROOT)\inc\crt flags_link=/RELEASE /LTCG /LIBPATH:$(WDKROOT)\lib\wxp\i386 /LIBPATH:$(WDKROOT)\lib\Crt\i386 !endif -ENGINEOPTS=/DSUPERBUILD /DPOLYMOST /DUSE_OPENGL /DPOLYMER +ENGINEOPTS=/DUSE_OPENGL /DPOLYMER CC=cl AS=ml diff --git a/polymer-perf/eduke32/build/Makefile b/polymer-perf/eduke32/build/Makefile index 6ee120a67..6799afdc7 100644 --- a/polymer-perf/eduke32/build/Makefile +++ b/polymer-perf/eduke32/build/Makefile @@ -46,7 +46,7 @@ else LIBS+= $(L_SSP) -Wl,--enable-auto-import endif -OURCFLAGS=$(BASECFLAGS) -Wno-char-subscripts -DKSFORBUILD -I$(INC) $(ARCH) +OURCFLAGS=$(BASECFLAGS) -Wno-char-subscripts -I$(INC) $(ARCH) OURCXXFLAGS=$(BASECXXFLAGS) ASFLAGS=$(BASEASFLAGS) diff --git a/polymer-perf/eduke32/build/Makefile.msvc b/polymer-perf/eduke32/build/Makefile.msvc index f1300c6d1..d78bcbb10 100644 --- a/polymer-perf/eduke32/build/Makefile.msvc +++ b/polymer-perf/eduke32/build/Makefile.msvc @@ -9,7 +9,7 @@ OBJ=obj.msc !endif INC=include\ # !ifndef CFLAGS -CFLAGS=/DSUPERBUILD /DPOLYMOST /DUSE_OPENGL /DKSFORBUILD /DPOLYMER # /DNEDMALLOC +CFLAGS=/DUSE_OPENGL /DPOLYMER # /DNEDMALLOC !endif o=obj diff --git a/polymer-perf/eduke32/build/Makefile.shared b/polymer-perf/eduke32/build/Makefile.shared index c43060d35..ae1348889 100644 --- a/polymer-perf/eduke32/build/Makefile.shared +++ b/polymer-perf/eduke32/build/Makefile.shared @@ -3,13 +3,12 @@ ENGINELIB=libengine.a EDITORLIB=libbuild.a -# SDLCONFIG = /usr/local/bin/sdl-config -SDLCONFIG = /usr/bin/sdl-config +SDLCONFIG = /usr/local/bin/sdl-configinvalid ifeq ($(wildcard $(SDLCONFIG)),$(SDLCONFIG)) SDLROOT = /usr/local else - SDLCONFIG = sdl-config + SDLCONFIG = /usr/bin/sdl-config endif SDL_FRAMEWORK = 0 @@ -184,12 +183,6 @@ endif BUILDCFLAGS+= -DRENDERTYPE$(RENDERTYPE)=1 -ifneq (0,$(SUPERBUILD)) - BUILDCFLAGS+= -DSUPERBUILD -endif -ifneq (0,$(POLYMOST)) - BUILDCFLAGS+= -DPOLYMOST -endif ifneq (0,$(USE_OPENGL)) BUILDCFLAGS+= -DUSE_OPENGL endif @@ -201,10 +194,8 @@ ifneq (0,$(LINKED_GTK)) endif ifneq (0,$(POLYMER)) - ifneq (0,$(POLYMOST)) - ifneq (0,$(USE_OPENGL)) - BUILDCFLAGS+= -DPOLYMER - endif + ifneq (0,$(USE_OPENGL)) + BUILDCFLAGS+= -DPOLYMER endif endif diff --git a/polymer-perf/eduke32/build/include/baselayer.h b/polymer-perf/eduke32/build/include/baselayer.h index ee3d8a9ad..5e29c59e8 100644 --- a/polymer-perf/eduke32/build/include/baselayer.h +++ b/polymer-perf/eduke32/build/include/baselayer.h @@ -81,6 +81,8 @@ extern char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend; extern char scantoasc[128], remap[256], key_names[256][24]; extern int32_t remapinit; +extern int32_t defaultres[][2]; + extern void SetKey(int32_t key, int32_t state); // mouse diff --git a/polymer-perf/eduke32/build/include/build.h b/polymer-perf/eduke32/build/include/build.h index d5737579e..37a53cd9e 100644 --- a/polymer-perf/eduke32/build/include/build.h +++ b/polymer-perf/eduke32/build/include/build.h @@ -29,6 +29,10 @@ extern "C" { #define MAXWALLSB ((MAXWALLS>>2)+(MAXWALLS>>3)) #define MAXSPRITES MAXSPRITESV8 +// additional space beyond wall, in walltypes: +#define M32_FIXME_WALLS 512 +#define M32_FIXME_SECTORS 2 + #define MAXTILES 15360 #define MAXVOXELS 4096 #define MAXSTATUS 1024 @@ -57,6 +61,17 @@ extern "C" { #define PR_LIGHT_PRIO_LOW 4 #define PR_LIGHT_PRIO_LOW_GAME 5 +////////// yax defs ////////// +#define YAX_BIT 1024 +#define YAX_CEILING 0 +#define YAX_FLOOR 1 + +#define YAX_SECTORFLD(Sect,Fld, Cf) (*((Cf) ? (§or[Sect].floor##Fld) : (§or[Sect].ceiling##Fld))) + +int16_t yax_getbunch(int16_t i, int16_t cf); +void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum); + + #define CLIPMASK0 (((1L)<<16)+1L) #define CLIPMASK1 (((256L)<<16)+64L) @@ -292,11 +307,10 @@ extern int32_t dommxoverlay, novoxmips; extern float debug1, debug2; -#ifdef SUPERBUILD extern int32_t tiletovox[MAXTILES]; extern int32_t usevoxels, voxscale[MAXVOXELS]; -#endif -#ifdef POLYMOST + +#ifdef USE_OPENGL extern int32_t usemodels, usehightile; extern int32_t rendmode; #endif @@ -313,7 +327,7 @@ EXTERN int32_t connecthead, connectpoint2[MAXPLAYERS]; static inline int32_t getrendermode(void) { -#ifndef POLYMOST +#ifndef USE_OPENGL return 0; #else return rendmode; @@ -465,7 +479,7 @@ void setview(int32_t x1, int32_t y1, int32_t x2, int32_t y2); void setaspect(int32_t daxrange, int32_t daaspect); void flushperms(void); -void plotlines2d(int32_t *xx, int32_t *yy, int32_t numpoints, char col) ATTRIBUTE((nonnull(1,2))); +void plotlines2d(const int32_t *xx, const int32_t *yy, int32_t numpoints, char col) ATTRIBUTE((nonnull(1,2))); void plotpixel(int32_t x, int32_t y, char col); char getpixel(int32_t x, int32_t y); @@ -491,7 +505,7 @@ int32_t clipinsideboxline(int32_t x, int32_t y, int32_t x1, int32_t y1, int32_ int32_t pushmove(vec3_t *vect, int16_t *sectnum, int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2))); void getzrange(const vec3_t *vect, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz, int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(1,3,4,5,6))); int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz, hitdata_t *hitinfo, uint32_t cliptype) ATTRIBUTE((nonnull(1,6))); -int32_t neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, int16_t *neartagsector, int16_t *neartagwall, int16_t *neartagsprite, int32_t *neartaghitdist, int32_t neartagrange, char tagsearch) ATTRIBUTE((nonnull(6,7,8))); +int32_t neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, int16_t *neartagsector, int16_t *neartagwall, int16_t *neartagsprite, int32_t *neartaghitdist, int32_t neartagrange, uint8_t tagsearch) ATTRIBUTE((nonnull(6,7,8))); int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, int32_t y2, int32_t z2, int16_t sect2); void updatesector(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3))); void updatesectorexclude(int32_t x, int32_t y, int16_t *sectnum, const uint8_t *excludesectbitmap) ATTRIBUTE((nonnull(3))); @@ -573,6 +587,8 @@ int32_t changespritesect(int16_t spritenum, int16_t newsectnum); int32_t changespritestat(int16_t spritenum, int16_t newstatnum); int32_t setsprite(int16_t spritenum, const vec3_t *new) ATTRIBUTE((nonnull(2))); +int32_t spriteheight(int16_t i, int32_t *basez); + int32_t screencapture(const char *filename, char inverseit) ATTRIBUTE((nonnull(1))); int32_t getclosestcol(int32_t r, int32_t g, int32_t b); @@ -601,7 +617,7 @@ void drawcircle16(int32_t x1, int32_t y1, int32_t r, int32_t eccen, char col); int32_t setrendermode(int32_t renderer); int32_t getrendermode(void); -#ifdef POLYMOST +#ifdef USE_OPENGL void setrollangle(int32_t rolla); #endif @@ -626,7 +642,7 @@ int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, i void polymost_glreset(void); void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL extern int32_t glanisotropy; extern int32_t glusetexcompr; extern int32_t gltexfiltermode; @@ -667,7 +683,7 @@ int32_t md_loadmodel(const char *fn); int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, int32_t flags); // int32_t md_tilehasmodel(int32_t tilenume, int32_t pal); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL typedef struct { // maps build tiles to particular animation frames of a model @@ -694,7 +710,7 @@ static inline int32_t md_tilehasmodel(int32_t tilenume,int32_t pal) int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume, int32_t skinnum, float smoothduration, int32_t pal); int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *frameend, int32_t fps, int32_t flags); int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum, int32_t surfnum, float param, float specpower, float specfactor); -int32_t md_definehud (int32_t modelid, int32_t tilex, double xadd, double yadd, double zadd, double angadd, int32_t flags); +int32_t md_definehud (int32_t modelid, int32_t tilex, double xadd, double yadd, double zadd, double angadd, int32_t flags, int32_t fov); int32_t md_undefinetile(int32_t tile); int32_t md_undefinemodel(int32_t modelid); @@ -727,7 +743,7 @@ void hash_add(hashtable_t *t, const char *s, int32_t key, int32_t replace); #ifdef POLYMER # include "polymer.h" #else -#ifdef POLYMOST +#ifdef USE_OPENGL # include "polymost.h" #endif #endif diff --git a/polymer-perf/eduke32/build/include/editor.h b/polymer-perf/eduke32/build/include/editor.h index 58615d4b7..c9658b804 100644 --- a/polymer-perf/eduke32/build/include/editor.h +++ b/polymer-perf/eduke32/build/include/editor.h @@ -11,7 +11,7 @@ extern "C" { #endif -#define VERSION " 2.0.0devel" +#define VERSION "2.0.0devel" // Build keys #define BK_MOVEFORWARD 0 @@ -39,8 +39,10 @@ extern "C" { extern int32_t qsetmode; extern int16_t searchsector, searchwall, searchstat; extern int16_t searchbottomwall; -extern int32_t zmode, kensplayerheight; -extern int16_t defaultspritecstat; +extern int32_t zmode, kensplayerheight, zlock; + +#define DEFAULT_SPRITE_CSTAT 0 +//extern int16_t defaultspritecstat; extern int32_t temppicnum, tempcstat, templotag, temphitag, tempextra; extern uint32_t temppal, tempvis, tempxrepeat, tempyrepeat; @@ -62,6 +64,7 @@ extern int16_t prefixtiles[16]; extern char program_origcwd[BMAX_PATH]; extern char *mapster32_fullpath; extern char *testplay_addparam; +extern const char *g_namesFileName; extern int32_t m32_osd_tryscript; extern int32_t showheightindicators; @@ -83,13 +86,15 @@ extern inline int32_t getscreenvdisp(int32_t bz, int32_t zoome); extern void setup_sideview_sincos(void); extern void m32_setkeyfilter(int32_t on); +extern int32_t wallength(int16_t i); +extern void fixrepeats(int16_t i); +extern void fixxrepeat(int16_t i, uint32_t lenrepquot); + extern int32_t ExtInit(void); extern int32_t ExtPreInit(int32_t argc,const char **argv); extern void ExtUnInit(void); extern void ExtPreCheckKeys(void); -#ifdef SUPERBUILD extern void ExtAnalyzeSprites(void); -#endif extern void ExtCheckKeys(void); extern void ExtPreLoadMap(void); extern void ExtLoadMap(const char *mapname); @@ -122,6 +127,8 @@ extern void showsectordata(int16_t sectnum, int16_t small); extern void showwalldata(int16_t wallnum, int16_t small); extern void showspritedata(int16_t spritenum, int16_t small); +extern void drawsmallabel(const char *text, char col, char backcol, int32_t dax, int32_t day, int32_t daz); + extern int32_t circlewall; int32_t loadsetup(const char *fn); // from config.c @@ -149,11 +156,19 @@ extern int32_t lastpm16time; extern char lastpm16buf[156]; +void DoSpriteOrnament(int32_t i); + void getpoint(int32_t searchxe, int32_t searchye, int32_t *x, int32_t *y); int32_t getpointhighlight(int32_t xplc, int32_t yplc, int32_t point); void update_highlight(); void update_highlightsector(); +int32_t inside_editor(const vec3_t *pos, int32_t searchx, int32_t searchy, int32_t zoom, + int32_t x, int32_t y, int16_t sectnum); +void correct_sprite_yoffset(int32_t i); + +extern uint8_t hlsectorbitmap[MAXSECTORS>>3]; + #ifdef _WIN32 #define DEFAULT_GAME_EXEC "eduke32.exe" #define DEFAULT_GAME_LOCAL_EXEC "eduke32.exe" @@ -169,21 +184,6 @@ void test_map(int32_t mode); #define POINT2(i) (wall[wall[i].point2]) #define SPRITESEC(j) (sector[sprite[j].sectnum]) -static inline int32_t wallength(int16_t i) -{ - int64_t dax = POINT2(i).x - wall[i].x; - int64_t day = POINT2(i).y - wall[i].y; -#if 1 //def POLYMOST - int64_t hypsq = dax*dax + day*day; - if (hypsq > (int64_t)INT_MAX) - return (int32_t)sqrt((double)hypsq); - else - return ksqrt((int32_t)hypsq); -#else - return ksqrt(dax*dax + day*day); -#endif -} - #define CLEARLINES2D(Startline, Numlines, Color) clearbuf((char *)(frameplace + ((Startline)*bytesperline)), (bytesperline*(Numlines))>>2, (Color)) #define SCRIPTHISTSIZ 32 // should be the same as OSD_HISTORYDEPTH for maximum win, should be a power of two @@ -222,4 +222,8 @@ extern int32_t scripthistend; Itervar < endwall; \ Itervar++ +#define BTAG_MAX 65535 +#define BZ_MAX 8388608 + + #endif diff --git a/polymer-perf/eduke32/build/include/mdsprite.h b/polymer-perf/eduke32/build/include/mdsprite.h index b59fd7467..22638bec3 100644 --- a/polymer-perf/eduke32/build/include/mdsprite.h +++ b/polymer-perf/eduke32/build/include/mdsprite.h @@ -231,9 +231,9 @@ void freeallmodels(void); void clearskins(void); int32_t mddraw(spritetype *tspr); -typedef struct { float xadd, yadd, zadd; int16_t angadd, flags; } hudtyp; +typedef struct { float xadd, yadd, zadd; int16_t angadd, flags, fov; } hudtyp; -EXTERN hudtyp hudmem[2][MAXTILES]; //~320KB ... ok for now ... could replace with dynamic alloc +EXTERN hudtyp hudmem[2][MAXTILES]; EXTERN int32_t mdpause; EXTERN int32_t nummodelsalloced, nextmodelid; diff --git a/polymer-perf/eduke32/build/include/polymer.h b/polymer-perf/eduke32/build/include/polymer.h index 60b52404c..cdc5efd68 100644 --- a/polymer-perf/eduke32/build/include/polymer.h +++ b/polymer-perf/eduke32/build/include/polymer.h @@ -53,6 +53,13 @@ extern int32_t pr_overridespecular; extern float pr_specularpower; extern float pr_specularfactor; extern int32_t pr_highpalookups; +extern int32_t pr_overridehud; +extern float pr_hudxadd; +extern float pr_hudyadd; +extern float pr_hudzadd; +extern int32_t pr_hudangadd; +extern int32_t pr_hudfov; +extern float pr_overridemodelscale; extern int32_t pr_ati_fboworkaround; extern int32_t pr_ati_nodepthoffset; #ifdef __APPLE__ @@ -283,13 +290,15 @@ typedef struct s_pranimatespritesinfo { // EXTERNAL FUNCTIONS int32_t polymer_init(void); void polymer_uninit(void); +void polymer_setaspect(int32_t); void polymer_glinit(void); void polymer_resetlights(void); void polymer_loadboard(void); void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, int16_t daang, int32_t dahoriz, int16_t dacursectnum); void polymer_drawmasks(void); void polymer_editorpick(void); -void polymer_rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, char dapalnum, int32_t dastat, int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2); +void polymer_inb4rotatesprite(int16_t tilenum, char pal, int8_t shade); +void polymer_postrotatesprite(void); void polymer_drawmaskwall(int32_t damaskwallcnt); void polymer_drawsprite(int32_t snum); void polymer_setanimatesprites(animatespritesptr animatesprites, int32_t x, int32_t y, int32_t a, int32_t smoothratio); diff --git a/polymer-perf/eduke32/build/include/polymost.h b/polymer-perf/eduke32/build/include/polymost.h index 1e4526f4a..720c24e06 100644 --- a/polymer-perf/eduke32/build/include/polymost.h +++ b/polymer-perf/eduke32/build/include/polymost.h @@ -1,7 +1,7 @@ #ifndef _polymost_h_ # define _polymost_h_ -#ifdef POLYMOST +#ifdef USE_OPENGL #include "hightile.h" diff --git a/polymer-perf/eduke32/build/src/baselayer.c b/polymer-perf/eduke32/build/src/baselayer.c index 3fc0f925e..f7c5d30c5 100644 --- a/polymer-perf/eduke32/build/src/baselayer.c +++ b/polymer-perf/eduke32/build/src/baselayer.c @@ -47,6 +47,14 @@ char scantoasc[128] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; +int32_t defaultres[][2] = +{ + {1920, 1440}, {1920, 1200}, {1920, 1080}, {1600, 1200}, {1600, 900}, {1366, 768}, {1280, 1024}, + {1280, 960}, {1152, 864}, {1024, 768}, {1024, 600}, {800, 600}, {640, 480}, {640, 400}, + {512, 384}, {480, 360}, {400, 300}, {320, 240}, {320, 200}, {0, 0} +}; + + void SetKey(int32_t key, int32_t state) { keystatus[remap[key]] = state; @@ -141,7 +149,7 @@ int32_t flushlogwindow = 1; static void onvideomodechange(int32_t newmode) { UNREFERENCED_PARAMETER(newmode); } void (*baselayer_onvideomodechange)(int32_t) = onvideomodechange; -#if defined(POLYMOST) +#ifdef USE_OPENGL static int32_t osdfunc_setrendermode(const osdfuncparm_t *parm) { int32_t m; @@ -312,7 +320,6 @@ int32_t baselayer_init(void) cvar_t cvars_engine[] = { -#ifdef SUPERBUILD { "r_usenewaspect","r_usenewaspect: enable/disable new screen aspect ratio determination code",(void *) &r_usenewaspect, CVAR_BOOL, 0, 1 }, { "r_screenaspect","r_screenaspect: if using the new aspect code and in fullscreen, screen aspect ratio in the form XXYY, e.g. 1609 for 16:9",(void *) &r_screenxy, CVAR_UINT, 100, 9999 }, { "r_novoxmips","r_novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",(void *) &novoxmips, CVAR_BOOL, 0, 1 }, @@ -321,7 +328,6 @@ int32_t baselayer_init(void) { "vid_gamma","vid_gamma : adjusts gamma ramp",(void *) &vid_gamma, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 }, { "vid_contrast","vid_contrast : adjusts gamma ramp",(void *) &vid_contrast, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 }, { "vid_brightness","vid_brightness : adjusts gamma ramp",(void *) &vid_brightness, CVAR_DOUBLE|CVAR_FUNCPTR, 0, 10 }, -#endif { "debug1","debug counter",(void *) &debug1, CVAR_FLOAT, -100000, 100000 }, { "debug2","debug counter",(void *) &debug2, CVAR_FLOAT, -100000, 100000 }, }; @@ -335,7 +341,7 @@ int32_t baselayer_init(void) (cvars_engine[i].type & CVAR_FUNCPTR) ? osdcmd_cvar_set_baselayer : osdcmd_cvar_set); } -#ifdef POLYMOST +#ifdef USE_OPENGL OSD_RegisterFunction("setrendermode","setrendermode : sets the engine's rendering mode.\n" "Mode numbers are:\n" " 0 - Classic Build software\n" diff --git a/polymer-perf/eduke32/build/src/build.c b/polymer-perf/eduke32/build/src/build.c index df646745d..6a7b85376 100644 --- a/polymer-perf/eduke32/build/src/build.c +++ b/polymer-perf/eduke32/build/src/build.c @@ -25,13 +25,12 @@ static int32_t crctable[256]; static char kensig[64]; +extern const char *ExtGetVer(void); extern int32_t ExtInit(void); extern int32_t ExtPreInit(int32_t argc,const char **argv); extern void ExtUnInit(void); extern void ExtPreCheckKeys(void); -#ifdef SUPERBUILD extern void ExtAnalyzeSprites(void); -#endif extern void ExtCheckKeys(void); extern void ExtLoadMap(const char *mapname); extern void ExtSaveMap(const char *mapname); @@ -99,7 +98,7 @@ extern int32_t cachesize, artsize; static int16_t oldmousebstatus = 0; char game_executable[BMAX_PATH] = DEFAULT_GAME_LOCAL_EXEC; int32_t zlock = 0x7fffffff, zmode = 0, whitecol, kensplayerheight = 32; -int16_t defaultspritecstat = 0; +//int16_t defaultspritecstat = 0; int16_t localartfreq[MAXTILES]; int16_t localartlookup[MAXTILES], localartlookupnum; @@ -107,6 +106,7 @@ int16_t localartlookup[MAXTILES], localartlookupnum; char tempbuf[4096]; char names[MAXTILES][25]; +const char *g_namesFileName = "NAMES.H"; int16_t asksave = 0; extern int16_t editstatus, searchit; @@ -155,6 +155,8 @@ static int32_t mousx, mousy; int16_t prefixtiles[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; uint8_t hlsectorbitmap[MAXSECTORS>>3]; // show2dsector is already taken... +static uint8_t visited[MAXWALLS>>3]; // used for AlignWalls and trace_loop + typedef struct { int16_t numsectors, numwalls, numsprites; @@ -220,7 +222,7 @@ static int32_t deletesector(int16_t sucksect); void fixrepeats(int16_t i); static int16_t loopinside(int32_t x, int32_t y, int16_t startwall); int32_t fillsector(int16_t sectnum, char fillcolor); -int16_t whitelinescan(int16_t dalinehighlight); +static int16_t whitelinescan(int16_t dalinehighlight); void printcoords16(int32_t posxe, int32_t posye, int16_t ange); static void copysector(int16_t soursector, int16_t destsector, int16_t deststartwall, char copystat, const int16_t *oldtonewsect); int32_t drawtilescreen(int32_t pictopleft, int32_t picbox); @@ -228,7 +230,7 @@ void overheadeditor(void); static int32_t getlinehighlight(int32_t xplc, int32_t yplc, int32_t line); void fixspritesectors(void); static int32_t movewalls(int32_t start, int32_t offs); -int32_t loadnames(void); +int32_t loadnames(const char *namesfile); void updatenumsprites(void); static void getclosestpointonwall(int32_t x, int32_t y, int32_t dawall, int32_t *nx, int32_t *ny); static void initcrc(void); @@ -238,6 +240,9 @@ int32_t gettile(int32_t tilenum); static int32_t menuselect(void); static int32_t menuselect_auto(int32_t); //PK +static int32_t insert_sprite_common(int32_t sucksect, int32_t dax, int32_t day); +static void correct_ornamented_sprite(int32_t i, int32_t hitw); + static int32_t getfilenames(const char *path, const char *kind); static void clearfilenames(void); void loadmhk(int32_t domessage); @@ -345,21 +350,24 @@ static void M32_drawdebug(void) int i; int x=4, y=8; - begindrawing(); #if 0 { static char tstr[128]; - Bsprintf(tstr, "searchstat=%d, searchsector=%d, searchwall=%d (%d)", - searchstat, searchsector, searchwall, searchbottomwall); + Bsprintf(tstr, "searchstat=%d, searchsector=%d, searchwall=%d (%d), asksave=%d", + searchstat, searchsector, searchwall, searchbottomwall, asksave); printext256(x,y,whitecol,0,tstr,xdimgame>640?0:1); } #endif - for (i=0; i0) { - y+=8; - printext256(x,y,whitecol,0,m32_debugstr[i],xdimgame>640?0:1); + begindrawing(); + for (i=0; i640?0:1); + } + enddrawing(); } - enddrawing(); m32_numdebuglines=0; } #endif @@ -442,10 +450,10 @@ int32_t app_main(int32_t argc, const char **argv) } #endif - loadnames(); + loadnames(g_namesFileName); if (initinput()) return -1; - // if (option[3] != 0) moustat = + initmouse(); inittimer(TIMERINTSPERSECOND); @@ -556,10 +564,9 @@ CANCEL: lockclock += synctics; drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); -#ifdef SUPERBUILD ExtAnalyzeSprites(); -#endif drawmasks(); + #ifdef POLYMER if (rendmode == 4 && searchit == 2) { @@ -709,57 +716,96 @@ void loadmhk(int32_t domessage) } } + +static void move_and_update(int32_t xvect, int32_t yvect, int32_t addshr) +{ + if (noclip) + { + pos.x += xvect>>(14+addshr); + pos.y += yvect>>(14+addshr); + updatesector(pos.x,pos.y, &cursectnum); + } + else + clipmove(&pos,&cursectnum, xvect>>addshr,yvect>>addshr, + 128,4<<8,4<<8, CLIPMASK0); +} + +static void mainloop_move() +{ + int32_t xvect, yvect, doubvel; + + if (angvel != 0) //ang += angvel * constant + { + //ENGINE calculates angvel for you + + //Lt. shift makes turn velocity 50% faster + doubvel = (synctics + DOWN_BK(RUN)*(synctics>>1)); + + ang += ((angvel*doubvel)>>4); + ang &= 2047; + } + if ((vel|svel) != 0) + { + //Lt. shift doubles forward velocity + doubvel = (1+(DOWN_BK(RUN)))*synctics; + + xvect = 0; + yvect = 0; + + if (vel != 0) + { + xvect += (vel*doubvel*(int32_t)sintable[(ang+2560)&2047])>>3; + yvect += (vel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3; + } + if (svel != 0) + { + xvect += (svel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3; + yvect += (svel*doubvel*(int32_t)sintable[(ang+1536)&2047])>>3; + } + + move_and_update(xvect, yvect, 0); + } +} + void editinput(void) { -// char smooshyalign, repeatpanalign, buffer[80]; -// short sectnum, nextsectnum, startwall, endwall, dasector, daang; int32_t mousz, bstatus; - int32_t i, j, k, /*cnt,*/ tempint=0, doubvel/*, changedir, wallfind[2], daz[2]*/; - int32_t /*dashade[2],*/ goalz, xvect, yvect,/*PK*/ zvect, hiz, loz; - hitdata_t hitinfo; - int32_t dax, day, hihit, lohit; + int32_t i, j, k, tempint=0; + int32_t goalz, xvect, yvect, hiz, loz; + int32_t dax, day, hihit, lohit, omlook=mlook; // 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 // F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL - /* if (keystatus[0x57] > 0) //F11 - brightness - { - keystatus[0x57] = 0; - brightness++; - if (brightness >= 16) brightness = 0; - setbrightness(brightness,palette,0); - } - if (keystatus[88] > 0) //F12 - { - screencapture("captxxxx.tga",eitherSHIFT); - keystatus[88] = 0; - }*/ - mousz = 0; getmousevalues(&mousx,&mousy,&bstatus); - mousx = (mousx<<16)+mousexsurp; - mousy = (mousy<<16)+mouseysurp; + mousx = (mousx<<16) + mousexsurp; + mousy = (mousy<<16) + mouseysurp; - if ((unrealedlook && !mskip) && - (((!mlook && (bstatus&2) && !(bstatus&(1|4)))) || ((bstatus&1) && !(bstatus&(2|4))))) - mlook = 3; + if (unrealedlook && !mskip) + { + if (mlook==0 && (bstatus&(1|2|4))==2) + mlook = 3; + else if ((bstatus&(1|2|4))==1) + mlook = 3; + } { ldiv_t ld; if (mlook) { - ld = ldiv((int32_t)(mousx), (int32_t)((1<<16)/(msens*0.5f))); mousx = ld.quot; mousexsurp = ld.rem; - ld = ldiv((int32_t)(mousy), (int32_t)((1<<16)/(msens*0.25f))); mousy = ld.quot; mouseysurp = ld.rem; + ld = ldiv(mousx, (int32_t)((1<<16)/(msens*0.5f))); mousx = ld.quot; mousexsurp = ld.rem; + ld = ldiv(mousy, (int32_t)((1<<16)/(msens*0.25f))); mousy = ld.quot; mouseysurp = ld.rem; } else { - ld = ldiv((int32_t)(mousx), (int32_t)((1<<16)/msens)); mousx = ld.quot; mousexsurp = ld.rem; - ld = ldiv((int32_t)(mousy), (int32_t)((1<<16)/msens)); mousy = ld.quot; mouseysurp = ld.rem; + ld = ldiv(mousx, (int32_t)((1<<16)/msens)); mousx = ld.quot; mousexsurp = ld.rem; + ld = ldiv(mousy, (int32_t)((1<<16)/msens)); mousy = ld.quot; mouseysurp = ld.rem; } } if (mlook == 3) - mlook = 0; + mlook = omlook; // UnrealEd: // rmb: mouselook @@ -769,39 +815,28 @@ void editinput(void) if (unrealedlook && !mskip) //PK { - if ((bstatus&1) && !(bstatus&(2|4))) + if ((bstatus&(1|2|4))==1) { ang += mousx; xvect = -((mousy*(int32_t)sintable[(ang+2560)&2047])<<(3+pk_uedaccel)); yvect = -((mousy*(int32_t)sintable[(ang+2048)&2047])<<(3+pk_uedaccel)); - if (noclip) - { - pos.x += xvect>>14; - pos.y += yvect>>14; - updatesector(pos.x,pos.y,&cursectnum); - } - else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); + move_and_update(xvect, yvect, 0); } - else if (!mlook && (bstatus&2) && !(bstatus&(1|4))) + else if (!mlook && (bstatus&(1|2|4))==2) { mlook=2; } - else if ((bstatus&1) && (bstatus&2) && !(bstatus&4)) + else if ((bstatus&(1|2|4))==(1|2)) { zmode = 2; xvect = -((mousx*(int32_t)sintable[(ang+2048)&2047])<>14; - pos.y += yvect>>14; - updatesectorz(pos.x,pos.y,pos.z,&cursectnum); - } - else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); + + move_and_update(xvect, yvect, 0); } - else if (bstatus&4) + else if ((bstatus&(1|2|4))==4) { zmode = 2; @@ -817,32 +852,31 @@ void editinput(void) ((int32_t)sintable[(tempint+512)&2047])>>6) <>(10-pk_uedaccel)); + pos.z += mousy*(((int32_t)sintable[(tempint+2048)&2047])>>(10-pk_uedaccel)); - pos.z += zvect; - if (noclip) - { - pos.x += xvect>>16; - pos.y += yvect>>16; - updatesectorz(pos.x,pos.y,pos.z,&cursectnum); - } - else clipmove(&pos,&cursectnum,xvect>>2,yvect>>2,128L,4L<<8,4L<<8,CLIPMASK0); + move_and_update(xvect, yvect, 2); } } if (mskip) - mskip=0; + { + // mskip was set in astub.c to not trigger UEd mouse movements. + // Reset now. + mskip = 0; + } else { - if (mlook && !(unrealedlook && bstatus&(1|4))) + if (mlook && (unrealedlook==0 || (bstatus&(1|4))==0)) { ang += mousx; horiz -= mousy; -// if (mousy && !(mousy/4)) - // horiz--; - // if (mousx && !(mousx/2)) - // ang++; + /* + if (mousy && !(mousy/4)) + horiz--; + if (mousx && !(mousx/2)) + ang++; + */ bclamp(&horiz, -99, 299); @@ -854,7 +888,7 @@ void editinput(void) osearchx = searchx-mousx; osearchy = searchy-mousy; } - else if (!(unrealedlook && (bstatus&(1|2|4)))) + else if (unrealedlook==0 || (bstatus&(1|2|4))==0) { osearchx = searchx; osearchy = searchy; @@ -880,7 +914,7 @@ void editinput(void) if (mhk) { Bmemset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES); - Bmemset(spritesmooth, 0, sizeof(spritesmooth_t) *(MAXSPRITES+MAXUNIQHUDID)); + Bmemset(spritesmooth, 0, sizeof(spritesmooth_t) * (MAXSPRITES+MAXUNIQHUDID)); delete_maphack_lights(); mhk = 0; message("Maphacks disabled"); @@ -894,51 +928,9 @@ void editinput(void) keystatus[0x43] = 0; } - if (angvel != 0) //ang += angvel * constant - { - //ENGINE calculates angvel for you - doubvel = synctics; - if (DOWN_BK(RUN)) //Lt. shift makes turn velocity 50% faster - doubvel += (synctics>>1); - ang += ((angvel*doubvel)>>4); - ang = (ang+2048)&2047; - } - if ((vel|svel) != 0) - { - //Lt. shift doubles forward velocity - doubvel = (1+(DOWN_BK(RUN)))*synctics; + mainloop_move(); - xvect = 0; - yvect = 0; - - if (vel != 0) - { - xvect += (vel*doubvel*(int32_t)sintable[(ang+2560)&2047])>>3; - yvect += (vel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3; - } - if (svel != 0) - { - xvect += (svel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3; - yvect += (svel*doubvel*(int32_t)sintable[(ang+1536)&2047])>>3; - } - if (noclip) - { - pos.x += xvect>>14; - pos.y += yvect>>14; - updatesector(pos.x,pos.y,&cursectnum); - } - else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); - } - - getzrange(&pos,cursectnum,&hiz,&hihit,&loz,&lohit,128L,CLIPMASK0); - - /* if (keystatus[0x3a] > 0) - { - zmode++; - if (zmode == 3) zmode = 0; - if (zmode == 1) zlock = (loz-pos.z)&0xfffffc00; - keystatus[0x3a] = 0; - }*/ + getzrange(&pos,cursectnum, &hiz,&hihit, &loz,&lohit, 128,CLIPMASK0); if (zmode == 0) { @@ -949,25 +941,15 @@ void editinput(void) if (DOWN_BK(MOVEUP)) //A (stand high) { - /* if (eitherCTRL) - horiz = max(-100,horiz-((DOWN_BK(RUN)+1)*synctics*2)); - else */ - { - goalz -= (16<<8); - if (DOWN_BK(RUN)) //Either shift key - goalz -= (24<<8); - } + goalz -= (16<<8); + if (DOWN_BK(RUN)) + goalz -= (24<<8); } if (DOWN_BK(MOVEDOWN)) //Z (stand low) { - /* if (eitherCTRL) - horiz = min(300,horiz+((DOWN_BK(RUN)+1)*synctics*2)); - else */ - { + goalz += (12<<8); + if (DOWN_BK(RUN)) goalz += (12<<8); - if (DOWN_BK(RUN)) //Either shift key - goalz += (12<<8); - } } if (goalz != pos.z) @@ -1030,8 +1012,10 @@ void editinput(void) { //if (pos.z < goalz) hvel += (32< goalz) hvel -= (32< goalz) hvel = ((synctics*-192)<= 0) { @@ -1053,9 +1039,11 @@ void editinput(void) if (keystatus[0x1f]) //S (insert sprite) (3D) { + hitdata_t hitinfo; + dax = 16384; - day = divscale14(searchx-(xdim>>1),xdim>>1); - rotatepoint(0,0,dax,day,ang,&dax,&day); + day = divscale14(searchx-(xdim>>1), xdim>>1); + rotatepoint(0,0, dax,day, ang, &dax,&day); hitscan((const vec3_t *)&pos,cursectnum, //Start position dax,day,(scale(searchy,200,ydim)-horiz)*2000, //vector of 3D ang @@ -1068,108 +1056,74 @@ void editinput(void) if (gridlock && grid > 0) { if (searchstat == 0 || searchstat == 4) - hitinfo.pos.z = (hitinfo.pos.z&0xfffffc00); + hitinfo.pos.z &= 0xfffffc00; else locktogrid(&dax, &day); } - i = insertsprite(hitinfo.hitsect,0); - sprite[i].x = dax, sprite[i].y = day; - sprite[i].cstat = defaultspritecstat; - sprite[i].shade = 0; - sprite[i].pal = 0; - sprite[i].xrepeat = 64, sprite[i].yrepeat = 64; - sprite[i].xoffset = 0, sprite[i].yoffset = 0; - sprite[i].ang = 1536; - sprite[i].xvel = 0; sprite[i].yvel = 0; sprite[i].zvel = 0; - sprite[i].owner = -1; - sprite[i].clipdist = 32; - sprite[i].lotag = 0; - sprite[i].hitag = 0; - sprite[i].extra = -1; + i = insert_sprite_common(hitinfo.hitsect, dax, day); - Bmemset(localartfreq, 0, sizeof(localartfreq)); - for (k=0; k localartfreq[j]) - j = k; - - if (localartfreq[j] > 0) - sprite[i].picnum = j; + if (i < 0) + message("Couldn't insert sprite."); else - sprite[i].picnum = 0; - - if (somethingintab == 3) { - sprite[i].picnum = temppicnum; - if ((tilesizx[temppicnum] <= 0) || (tilesizy[temppicnum] <= 0)) + int32_t cz, fz; + + if (somethingintab == 3) { - j = 0; - for (k=0; k 0) && (tilesizy[k] > 0)) - { - j = k; - break; - } - sprite[i].picnum = j; + sprite[i].picnum = temppicnum; + if (tilesizx[temppicnum] <= 0 || tilesizy[temppicnum] <= 0) + { + j = 0; + for (k=0; k 0 && tilesizy[k] > 0) + { + j = k; + break; + } + sprite[i].picnum = j; + } + + sprite[i].shade = tempshade; + sprite[i].pal = temppal; + sprite[i].xrepeat = max(tempxrepeat, 1); + sprite[i].yrepeat = max(tempyrepeat, 1); + sprite[i].cstat = tempcstat; } - sprite[i].shade = tempshade; - sprite[i].pal = temppal; - sprite[i].xrepeat = max(tempxrepeat, 1); - sprite[i].yrepeat = max(tempyrepeat, 1); - sprite[i].cstat = tempcstat; - } + getzsofslope(hitinfo.hitsect, hitinfo.pos.x, hitinfo.pos.y, &cz, &fz); - j = ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - if ((sprite[i].cstat&128) == 0) - sprite[i].z = min(max(hitinfo.pos.z, - getceilzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)+(j<<1)), - getflorzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)); - else - sprite[i].z = min(max(hitinfo.pos.z, - getceilzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)+j), - getflorzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)-j); - - if (searchstat == 0 || searchstat == 4) - { - sprite[i].cstat = (sprite[i].cstat&~48)|(16+64); - if (hitinfo.hitwall >= 0) - sprite[i].ang = (getangle(POINT2(hitinfo.hitwall).x-wall[hitinfo.hitwall].x, - POINT2(hitinfo.hitwall).y-wall[hitinfo.hitwall].y)+512)&2047; - - //Make sure sprite's in right sector - if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) + j = spriteheight(i, NULL)>>1; + sprite[i].z = hitinfo.pos.z; + if ((sprite[i].cstat&48)!=32) { - j = wall[hitinfo.hitwall].point2; - sprite[i].x -= ksgn(wall[j].y-wall[hitinfo.hitwall].y); - sprite[i].y += ksgn(wall[j].x-wall[hitinfo.hitwall].x); + if ((sprite[i].cstat&128) == 0) + bclamp(&sprite[i].z, cz+(j<<1), fz); + else + bclamp(&sprite[i].z, cz+j, fz-j); } + + if (searchstat == 0 || searchstat == 4) + { + sprite[i].cstat &= ~48; + sprite[i].cstat |= (16+64); + + correct_ornamented_sprite(i, hitinfo.hitwall); + } + else + sprite[i].cstat |= (tilesizy[sprite[i].picnum]>=32); + + correct_sprite_yoffset(i); + + updatenumsprites(); + asksave = 1; + + VM_OnEvent(EVENT_INSERTSPRITE3D, i); } - else - sprite[i].cstat |= (tilesizy[sprite[i].picnum]>=32); - - updatenumsprites(); - asksave = 1; - - VM_OnEvent(EVENT_INSERTSPRITE3D, i); } keystatus[0x1f] = 0; } - /* if (keystatus[0xd3] > 0) - { - if (searchstat == 3) - { - deletesprite(searchwall); - updatenumsprites(); - asksave = 1; - } - keystatus[0xd3] = 0; - }*/ if (keystatus[0x3f]||keystatus[0x40]) //F5,F6 { @@ -1184,7 +1138,8 @@ void editinput(void) case 3: ExtShowSpriteData(searchwall); break; } - keystatus[0x3f] = 0, keystatus[0x40] = 0; + + keystatus[0x3f] = keystatus[0x40] = 0; } if (keystatus[0x41]||keystatus[0x42]) //F7,F8 { @@ -1199,7 +1154,8 @@ void editinput(void) case 3: ExtEditSpriteData(searchwall); break; } - keystatus[0x41] = 0, keystatus[0x42] = 0; + + keystatus[0x41] = keystatus[0x42] = 0; } } @@ -1259,15 +1215,56 @@ char changechar(char dachar, int32_t dadir, char smooshyalign, char boundcheck) ////////////////////// OVERHEADEDITOR ////////////////////// +int32_t inside_editor(const vec3_t *pos, int32_t searchx, int32_t searchy, int32_t zoom, + int32_t x, int32_t y, int16_t sectnum) +{ + if (!m32_sideview) + return inside(x, y, sectnum); + + // if in side-view mode, use the screen coords instead + { + int32_t dst = MAXSECTORS+M32_FIXME_SECTORS-1, i, oi; + int32_t srcw=sector[sectnum].wallptr, dstw=MAXWALLS; + int32_t ret; + + if (sector[sectnum].wallnum > M32_FIXME_WALLS) + return -1; + + Bmemcpy(§or[dst], §or[sectnum], sizeof(sectortype)); + sector[dst].wallptr = dstw; + + Bmemcpy(&wall[dstw], &wall[srcw], sector[dst].wallnum*sizeof(walltype)); + for (i=dstw, oi=srcw; ix, wall[i].y-pos->y, zoom); + wall[i].y += getscreenvdisp(getflorzofslope(sectnum,wall[oi].x,wall[oi].y)-pos->z, zoom); + wall[i].x += halfxdim16; + wall[i].y += midydim16; + } + + i = numsectors; + numsectors = dst+1; + ret = inside(searchx, searchy, dst); + numsectors = i; + return ret; + } +} + static inline void drawline16base(int32_t bx, int32_t by, int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col) { drawline16(bx+x1, by+y1, bx+x2, by+y2, col); } -static void drawsmalllabel(const char *text, char col, char backcol, int32_t dax, int32_t day) +void drawsmallabel(const char *text, char col, char backcol, int32_t dax, int32_t day, int32_t daz) { int32_t x1, y1, x2, y2; + screencoords(&dax,&day, dax-pos.x,day-pos.y, zoom); + if (m32_sideview) + day += getscreenvdisp(daz-pos.z, zoom); + x1 = halfxdim16+dax-(Bstrlen(text)<<1); y1 = midydim16+day-4; x2 = x1 + (Bstrlen(text)<<2)+2; @@ -1401,7 +1398,7 @@ static int32_t restore_highlighted_map(mapinfofull_t *mapinfo) for (i=numwalls; i>3] |= (1<<(i&7)); } for (i=numwalls; i= 0) + sprite[i].ang = (getangle(POINT2(hitw).x-wall[hitw].x, + POINT2(hitw).y-wall[hitw].y)+512)&2047; + + //Make sure sprite's in right sector + if (inside(sprite[i].x, sprite[i].y, sprite[i].sectnum) == 0) + { + j = wall[hitw].point2; + sprite[i].x -= ksgn(wall[j].y-wall[hitw].y); + sprite[i].y += ksgn(wall[j].x-wall[hitw].x); + } +} + +void DoSpriteOrnament(int32_t i) +{ + hitdata_t hitinfo; + + hitscan((const vec3_t *)&sprite[i],sprite[i].sectnum, + sintable[(sprite[i].ang+1536)&2047], + sintable[(sprite[i].ang+1024)&2047], + 0, + &hitinfo,CLIPMASK1); + + sprite[i].x = hitinfo.pos.x; + sprite[i].y = hitinfo.pos.y; + sprite[i].z = hitinfo.pos.z; + changespritesect(i, hitinfo.hitsect); + + correct_ornamented_sprite(i, hitinfo.hitwall); +} + void update_highlight() { int32_t i; @@ -1632,7 +1664,7 @@ void update_highlightsector() } // hook run after handleevents in side view -static void sideview_filter_keys() +static void sideview_filter_keys(void) { uint32_t i; @@ -1642,7 +1674,7 @@ static void sideview_filter_keys() { case 0xd2: case 0xd3: // ins, del case 0x2e: case 0x39: // c, space - case 0xb8: // ralt +// case 0xb8: // ralt keystatus[i] = 0; break; } @@ -1660,18 +1692,301 @@ void m32_setkeyfilter(int32_t on) after_handleevents_hook = 0; } -static int32_t ask_if_sure(const char *query, int32_t quit_is_yes); +// Get average point of sectors +static void get_sectors_center(const int16_t *sectors, int32_t numsecs, int32_t *cx, int32_t *cy) +{ + int32_t i, j, k=0, dax = 0, day = 0; + int32_t startwall, endwall; + + for (i=0; i 0) + { + dax /= k; + day /= k; + } + + *cx = dax; + *cy = day; +} + +static int32_t insert_sprite_common(int32_t sucksect, int32_t dax, int32_t day) +{ + int32_t i, j, k; + + i = insertsprite(sucksect,0); + if (i < 0) + return -1; + + sprite[i].x = dax, sprite[i].y = day; + sprite[i].cstat = DEFAULT_SPRITE_CSTAT; + sprite[i].shade = 0; + sprite[i].pal = 0; + sprite[i].xrepeat = 64, sprite[i].yrepeat = 64; + sprite[i].xoffset = 0, sprite[i].yoffset = 0; + sprite[i].ang = 1536; + sprite[i].xvel = 0; sprite[i].yvel = 0; sprite[i].zvel = 0; + sprite[i].owner = -1; + sprite[i].clipdist = 32; + sprite[i].lotag = 0; + sprite[i].hitag = 0; + sprite[i].extra = -1; + + Bmemset(localartfreq, 0, sizeof(localartfreq)); + for (k=0; k localartfreq[j]) + j = k; + + if (localartfreq[j] > 0) + sprite[i].picnum = j; + else + sprite[i].picnum = 0; + + return i; +} + +void correct_sprite_yoffset(int32_t i) +{ + int32_t tileyofs = (int8_t)((picanm[sprite[i].picnum]>>16)&255); + int32_t tileysiz = tilesizy[sprite[i].picnum]; + + if (klabs(tileyofs) >= tileysiz) + { + tileyofs *= -1; + if (tileyofs == 128) + tileyofs = 127; + + sprite[i].yoffset = tileyofs; + } + else + sprite[i].yoffset = 0; +} + +static void fade_screen() +{ + char blackcol=editorcolors[0], greycol=whitecol-25, *cp; + int32_t i; + + begindrawing(); + cp = (char *)frameplace; + for (i=0; i= 0 ? &wall[src] : &nullwall; + + dstwal->cstat = srcwal->cstat; + dstwal->shade = srcwal->shade; + dstwal->yrepeat = srcwal->yrepeat; + fixrepeats(dst); // xrepeat + dstwal->picnum = srcwal->picnum; + dstwal->overpicnum = srcwal->overpicnum; + + dstwal->nextwall = -1; + dstwal->nextsector = -1; + + dstwal->pal = srcwal->pal; + dstwal->xpanning = srcwal->xpanning; + dstwal->ypanning = srcwal->ypanning; + dstwal->lotag = 0; //srcwal->lotag; + dstwal->hitag = 0; //srcwal->hitag; + dstwal->extra = -1; //srcwal->extra; +} + +// helpers for often needed ops: +static int32_t copyloop1(int16_t *danumwalls, int32_t *m) +{ + if (*danumwalls >= MAXWALLS + M32_FIXME_WALLS) + return 1; + + Bmemcpy(&wall[*danumwalls], &wall[*m], sizeof(walltype)); + wall[*danumwalls].point2 = *danumwalls+1; + (*danumwalls)++; + *m = wall[*m].point2; + + return 0; +} + +static void updatesprite1(int16_t i) +{ + setsprite(i, (vec3_t *)&sprite[i]); + + if (sprite[i].sectnum>=0) + { + int32_t tempint, cz, fz; + tempint = spriteheight(i, NULL); + if (sprite[i].cstat&128) + tempint >>= 1; + getzsofslope(sprite[i].sectnum, sprite[i].x, sprite[i].y, &cz, &fz); + sprite[i].z = max(sprite[i].z, cz+tempint); + sprite[i].z = min(sprite[i].z, fz); + } +} + +static int32_t ask_if_sure(const char *query, uint32_t flags); +static int32_t ask_above_or_below(); + +// returns: +// 0: continue +// >0: newnumwalls +// <0: error +static int32_t trace_loop(int32_t j, uint8_t *visitedwall, int16_t *ignore_ret, int16_t *refsect_ret) +{ + int16_t refsect, ignore; + int32_t k, n, refwall; + + if (wall[j].nextwall>=0 || (visitedwall[j>>3]&(1<<(j&7)))) + return 0; + + n=2*MAXWALLS; // simple inf loop check + refwall = j; + k = numwalls; + + ignore = 0; + + if (ignore_ret) + { + refsect = -1; + updatesectorexclude(wall[j].x, wall[j].y, &refsect, hlsectorbitmap); + if (refsect<0) + return -1; + } + + do + { + if (j!=refwall && visitedwall[j>>3]&(1<<(j&7))) + ignore = 1; + visitedwall[j>>3] |= (1<<(j&7)); + + if (ignore_ret) + { + if (inside(wall[j].x, wall[j].y, refsect) != 1) + ignore = 1; + } + + if (!ignore) + { + if (k>=MAXWALLS) + { + message("Wall limits exceeded while tracing outer loop."); + return -2; + } + + Bmemcpy(&wall[k], &wall[j], sizeof(walltype)); + wall[k].point2 = k+1; + wall[k].nextsector = wall[k].nextwall = wall[k].extra = -1; + k++; + } + + j = wall[j].point2; + n--; + + while (wall[j].nextwall>=0 && n>0) + { + j = wall[wall[j].nextwall].point2; +// if (j!=refwall && (visitedwall[j>>3]&(1<<(j&7)))) +// ignore = 1; +// visitedwall[j>>3] |= (1<<(j&7)); + n--; + } + } + while (j!=refwall && n>0); + + if (j!=refwall) + { + message("internal error while tracing outer loop: didn't reach refwall"); + return -3; + } + + if (ignore_ret) + { + *ignore_ret = ignore; + if (refsect_ret) + *refsect_ret = refsect; + } + + return k; +} + +static int32_t backup_drawn_walls(int32_t restore) +{ + static int32_t wallsdrawn = -1; + static walltype *tmpwall; + + // back up + if (restore==0) + { + if (newnumwalls == -1) + { + wallsdrawn = -1; + } + else + { + wallsdrawn = newnumwalls-numwalls; + + tmpwall = Bmalloc(wallsdrawn * sizeof(walltype)); + if (!tmpwall) + { + wallsdrawn = -1; + return 1; + } + + Bmemcpy(tmpwall, &wall[numwalls], wallsdrawn*sizeof(walltype)); + newnumwalls = -1; + } + + return 0; + } + + // restore + if (wallsdrawn != -1) + { + int32_t i; + + Bmemcpy(&wall[numwalls], tmpwall, wallsdrawn*sizeof(walltype)); + newnumwalls = numwalls + wallsdrawn; + for (i=numwalls; i 0) pos.x--, keystatus[0x3b] = 0; - if (keystatus[0x3c] > 0) pos.x++, keystatus[0x3c] = 0; - if (keystatus[0x3d] > 0) pos.y--, keystatus[0x3d] = 0; - if (keystatus[0x3e] > 0) pos.y++, keystatus[0x3e] = 0; - if (keystatus[0x43] > 0) ang--, keystatus[0x43] = 0; - if (keystatus[0x44] > 0) ang++, keystatus[0x44] = 0; */ + /* + if (keystatus[0x3b] > 0) pos.x--, keystatus[0x3b] = 0; + if (keystatus[0x3c] > 0) pos.x++, keystatus[0x3c] = 0; + if (keystatus[0x3d] > 0) pos.y--, keystatus[0x3d] = 0; + if (keystatus[0x3e] > 0) pos.y++, keystatus[0x3e] = 0; + if (keystatus[0x43] > 0) ang--, keystatus[0x43] = 0; + if (keystatus[0x44] > 0) ang++, keystatus[0x44] = 0; + */ - if (angvel != 0) //ang += angvel * constant - { - //ENGINE calculates angvel for you - doubvel = synctics; - if (DOWN_BK(RUN)) //Lt. shift makes turn velocity 50% faster - doubvel += (synctics>>1); - ang += ((angvel*doubvel)>>4); - ang = (ang+2048)&2047; - } - if ((vel|svel) != 0) - { - doubvel = synctics; - if (DOWN_BK(RUN)) //Lt. shift doubles forward velocity - doubvel += synctics; - xvect = 0, yvect = 0; - if (vel != 0) - { - xvect += (vel*doubvel*(int32_t)sintable[(ang+2560)&2047])>>3; - yvect += (vel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3; - } - if (svel != 0) - { - xvect += (svel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3; - yvect += (svel*doubvel*(int32_t)sintable[(ang+1536)&2047])>>3; - } - if (noclip) - { - pos.x += xvect>>14; - pos.y += yvect>>14; - updatesector(pos.x,pos.y,&cursectnum); - } - else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); - } + mainloop_move(); getpoint(searchx,searchy,&mousxplc,&mousyplc); linehighlight = getlinehighlight(mousxplc, mousyplc, linehighlight); @@ -1854,7 +2140,8 @@ void overheadeditor(void) tempint = numwalls; numwalls = newnumwalls; - if (numwalls < 0) numwalls = tempint; + if (numwalls < 0) + numwalls = tempint; if ((getticks() - lastdraw) >= 5 || (vel|angvel|svel) || DOWN_BK(MOVEUP) || DOWN_BK(MOVEDOWN) || mousx || mousy || bstatus || keystatus[0x10] || keystatus[0x11] @@ -1868,7 +2155,7 @@ void overheadeditor(void) if (graphicsmode && !m32_sideview) { - Bmemset(show2dsector, 255, sizeof(show2dsector)); + Bmemset(show2dsector, 0xff, sizeof(show2dsector)); setview(0, 0, xdim-1, ydim16-1); if (graphicsmode == 2) @@ -1907,7 +2194,6 @@ void overheadeditor(void) } draw2dscreen(&pos,cursectnum,ang,zoom,grid); - VM_OnEvent(EVENT_DRAW2DSCREEN, -1); begindrawing(); //{{{ if (showtags == 1) @@ -1916,39 +2202,23 @@ void overheadeditor(void) { for (i=0; i 0) - { - dax /= sector[i].wallnum; - day /= sector[i].wallnum; - } + get_sectors_center(&secshort, 1, &dax, &day); - if (m32_sideview) - vdisp = getscreenvdisp(getflorzofslope(i,dax,day)-pos.z, zoom); - screencoords(&dax,&day, dax-pos.x,day-pos.y, zoom); - if (m32_sideview) - day += vdisp; - - drawsmalllabel(dabuffer, editorcolors[0], editorcolors[7], dax, day); - } + drawsmallabel(dabuffer, editorcolors[0], editorcolors[7], + dax, day, getflorzofslope(i,dax,day)); } } - x3 = divscale14(-halfxdim16,zoom)+pos.x; - y3 = divscale14(-(midydim16-4),zoom)+pos.y; - x4 = divscale14(halfxdim16,zoom)+pos.x; - y4 = divscale14(ydim16-(midydim16-4),zoom)+pos.y; + x3 = pos.x + divscale14(-halfxdim16,zoom); + y3 = pos.y + divscale14(-(midydim16-4),zoom); + x4 = pos.x + divscale14(halfxdim16,zoom); + y4 = pos.y + divscale14(ydim16-(midydim16-4),zoom); if (newnumwalls >= 0) { @@ -1961,7 +2231,8 @@ void overheadeditor(void) i = newnumwalls-1; for (wal=&wall[i]; i>=0; i--,wal--) { - if (zoom < 768 && !(wal->cstat & (1<<14))) continue; + if (zoom < 768 && !(wal->cstat & (1<<14))) + continue; //Get average point of wall dax = (wal->x+wall[wal->point2].x)>>1; @@ -1969,14 +2240,11 @@ void overheadeditor(void) if ((dax > x3) && (dax < x4) && (day > y3) && (day < y4)) { dabuffer = (char *)ExtGetWallCaption(i); - if (dabuffer[0] != 0) - { - screencoords(&dax,&day, dax-pos.x,day-pos.y, zoom); - if (m32_sideview) - day += getscreenvdisp(getflorzofslope(sectorofwall(i), dax,day)-pos.z, zoom); + if (dabuffer[0] == 0) + continue; - drawsmalllabel(dabuffer, editorcolors[0], editorcolors[31], dax, day); - } + drawsmallabel(dabuffer, editorcolors[0], editorcolors[31], + dax, day, getflorzofslope(sectorofwall(i), dax,day)); } } @@ -1997,42 +2265,41 @@ void overheadeditor(void) dabuffer = (char *)ExtGetSpriteCaption(i); if (dabuffer[0] != 0) { - //Get average point of sprite - dax = sprite[i].x; - day = sprite[i].y; + int32_t blocking = (sprite[i].cstat&1); - screencoords(&dax,&day, dax-pos.x,day-pos.y, zoom); - if (m32_sideview) - day += getscreenvdisp(sprite[i].z-pos.z, zoom); + col = 3 + 2*blocking; + if (spritecol2d[sprite[i].picnum][blocking]) + col = spritecol2d[sprite[i].picnum][blocking]; - { - int32_t blocking = (sprite[i].cstat&1); + if ((i == pointhighlight-16384) && (totalclock & 32)) + col += (2<<2); - col = 3 + 2*blocking; - if (spritecol2d[sprite[i].picnum][blocking]) - col = spritecol2d[sprite[i].picnum][blocking]; - - if ((i == pointhighlight-16384) && (totalclock & 32)) - col += (2<<2); - - drawsmalllabel(dabuffer, editorcolors[0], editorcolors[col], dax, day); - } + drawsmallabel(dabuffer, editorcolors[0], editorcolors[col], + sprite[i].x, sprite[i].y, sprite[i].z); } j--; } - i++; } } + // stick this event right between begin- end enddrawing()... + // also after the above label stuff so users can redefine them + VM_OnEvent(EVENT_DRAW2DSCREEN, -1); + printcoords16(pos.x,pos.y,ang); numwalls = tempint; - if (highlightsectorcnt >= 0 && !m32_sideview) + if (highlightsectorcnt >= 0) + { + int32_t oydim16 = ydim16; + ydim16 = ydim-STATUS2DSIZ2; for (i=0; i>3]&(1<<(i&7))) fillsector(i,2); + ydim16 = oydim16; + } if (keystatus[0x2a]) // FIXME { @@ -2082,7 +2349,7 @@ void overheadeditor(void) printext16(8,8, editorcolors[13],editorcolors[0],cbuf,0); } - if ((keystatus[0x36] || keystatus[0xb8]) && !eitherCTRL) // RSHIFT || RALT + if (keystatus[0x36] || keystatus[0xb8]) // RSHIFT || RALT { if (keystatus[0x27] || keystatus[0x28]) // ' and ; { @@ -2092,6 +2359,9 @@ void overheadeditor(void) if (keystatus[0x28]) drawline16base(searchx+16, searchy-16, 0,-4, 0,+4, col); } + + if (keystatus[0x36] && eitherCTRL) + printext16(searchx+6,searchy-6-8,editorcolors[12],-1,"S",0); } drawline16base(searchx,searchy, +0,-8, +0,-1, col); @@ -2106,14 +2376,12 @@ void overheadeditor(void) ////// Draw the white pixel closest to mouse cursor on linehighlight if (linehighlight>=0 && !m32_sideview) { - getclosestpointonwall(mousxplc,mousyplc,(int32_t)linehighlight,&dax,&day); + getclosestpointonwall(mousxplc,mousyplc, linehighlight, &dax,&day); x2 = mulscale14(dax-pos.x,zoom); y2 = mulscale14(day-pos.y,zoom); - if (wall[linehighlight].nextsector >= 0) - drawline16base(halfxdim16+x2,midydim16+y2, 0,0, 0,0, editorcolors[15]); - else - drawline16base(halfxdim16+x2,midydim16+y2, 0,0, 0,0, editorcolors[5]); + drawline16base(halfxdim16+x2,midydim16+y2, 0,0, 0,0, + wall[linehighlight].nextsector >= 0 ? editorcolors[15] : editorcolors[5]); } enddrawing(); //}}} @@ -2128,36 +2396,16 @@ void overheadeditor(void) if (keystatus[0x2d] || keystatus[0x15]) // X or Y (2D) { int32_t about_x=keystatus[0x2d]; + int32_t doMirror = eitherALT; // mirror walls and wall/floor sprites if (highlightsectorcnt > 0) { keystatus[0x2d] = keystatus[0x15] = 0; - k = 0; - dax = 0; - day = 0; - - for (i=0; i 0) - { - dax /= k; - day /= k; - } - - k = eitherALT; //ALT-X/Y mirror sector in x/y + get_sectors_center(highlightsector, highlightsectorcnt, &dax, &day); if (gridlock && grid > 0) locktogrid(&dax, &day); - // dax = ((dax+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1)); - // day = ((day+(GRIDMAX>>grid))&(0xffffffff-(GRIDMAX>>(grid-1))+1)); for (i=0; i>1; for (w=1; w<=numtoswap; w++) { - Bmemcpy(&tempwall,&wall[startofloop+w],sizeof(walltype)); - Bmemcpy(&wall[startofloop+w],&wall[endofloop-w+1],sizeof(walltype)); - Bmemcpy(&wall[endofloop-w+1],&tempwall,sizeof(walltype)); + Bmemcpy(&tempwall, &wall[startofloop+w], sizeof(walltype)); + Bmemcpy(&wall[startofloop+w], &wall[endofloop-w+1], sizeof(walltype)); + Bmemcpy(&wall[endofloop-w+1], &tempwall, sizeof(walltype)); } //make point2 point to next wall in loop @@ -2250,7 +2496,7 @@ void overheadeditor(void) sprite[j].ang = (2048-sprite[j].ang)&2047; //flip ang about 512 } - if (k && (sprite[j].cstat & 0x30)) + if (doMirror && (sprite[j].cstat & 0x30)) sprite[j].cstat ^= 4; // mirror sprites about dax/day (don't mirror monsters) j = nextspritesect[j]; @@ -2304,9 +2550,10 @@ void overheadeditor(void) linehighlight = getlinehighlight(mousxplc, mousyplc, linehighlight); if (linehighlight >= 0) { - setfirstwall(sectorofwall(linehighlight),linehighlight); + int32_t secti = sectorofwall(linehighlight); + setfirstwall(secti, linehighlight); asksave = 1; - printmessage16("This wall now sector's first wall (sector[].wallptr)"); + printmessage16("This wall now sector %d's first wall (sector[].wallptr)", secti); } } } @@ -2317,28 +2564,7 @@ void overheadeditor(void) if ((pointhighlight&0xc000) == 16384) { asksave = 1; - i = (pointhighlight&16383); - - hitscan((const vec3_t *)&sprite[i],sprite[i].sectnum, - sintable[(sprite[i].ang+2560+1024)&2047], - sintable[(sprite[i].ang+1024)&2047], - 0,&hitinfo,CLIPMASK1); - - sprite[i].x = hitinfo.pos.x; - sprite[i].y = hitinfo.pos.y; - sprite[i].z = hitinfo.pos.z; - changespritesect(i,hitinfo.hitsect); - if (hitinfo.hitwall >= 0) - sprite[i].ang = (getangle(POINT2(hitinfo.hitwall).x - wall[hitinfo.hitwall].x, - POINT2(hitinfo.hitwall).y - wall[hitinfo.hitwall].y)+512)&2047; - - //Make sure sprite's in right sector - if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) - { - j = wall[hitinfo.hitwall].point2; - sprite[i].x -= ksgn(wall[j].y-wall[hitinfo.hitwall].y); - sprite[i].y += ksgn(wall[j].x-wall[hitinfo.hitwall].x); - } + DoSpriteOrnament(pointhighlight&16383); } } @@ -2353,27 +2579,11 @@ void overheadeditor(void) { if (highlightsectorcnt > 0) { - k = 0; - dax = 0; - day = 0; - for (i=0; i 0) - { - dax /= k; - day /= k; - } + int32_t smoothRotation = !eitherSHIFT; - k = eitherSHIFT; + get_sectors_center(highlightsector, highlightsectorcnt, &dax, &day); - if (k == 0) + if (smoothRotation) { if (gridlock && grid > 0) locktogrid(&dax, &day); @@ -2383,7 +2593,7 @@ void overheadeditor(void) { for (WALLS_OF_SECTOR(highlightsector[i], j)) { - if (k == 0) + if (smoothRotation) { x3 = wall[j].x; y3 = wall[j].y; @@ -2394,27 +2604,27 @@ void overheadeditor(void) rotatepoint(dax,day, wall[j].x,wall[j].y, tsign&2047, &wall[j].x,&wall[j].y); } - j = headspritesect[highlightsector[i]]; - while (j != -1) + for (j=headspritesect[highlightsector[i]]; j != -1; j=nextspritesect[j]) { - if (k == 0) + if (smoothRotation) { x3 = sprite[j].x; y3 = sprite[j].y; sprite[j].x = dax + tsign*(day-y3); sprite[j].y = day + tsign*(x3-dax); - sprite[j].ang = ((sprite[j].ang+tsign*512)&2047); + sprite[j].ang = (sprite[j].ang+tsign*512)&2047; } else { - rotatepoint(dax,day, sprite[j].x,sprite[j].y, tsign&2048, &sprite[j].x,&sprite[j].y); - sprite[j].ang = ((sprite[j].ang+tsign)&2047); + rotatepoint(dax,day, sprite[j].x,sprite[j].y, tsign&2047, &sprite[j].x,&sprite[j].y); + sprite[j].ang = (sprite[j].ang+tsign)&2047; } - - j = nextspritesect[j]; } } - if (k == 0) keystatus[0x33] = keystatus[0x34] = 0; + + if (smoothRotation) + keystatus[0x33] = keystatus[0x34] = 0; + mouseb &= ~(16|32); bstatus &= ~(16|32); asksave = 1; @@ -2425,10 +2635,10 @@ void overheadeditor(void) { i = pointhighlight-16384; if (eitherSHIFT) - sprite[i].ang = ((sprite[i].ang-tsign)&2047); + sprite[i].ang = (sprite[i].ang-tsign)&2047; else { - sprite[i].ang = ((sprite[i].ang-128*tsign)&2047); + sprite[i].ang = (sprite[i].ang-128*tsign)&2047; keystatus[0x33] = keystatus[0x34] = 0; } @@ -2451,7 +2661,7 @@ void overheadeditor(void) keystatus[0x46] = 0; asksave = 1; } - +#if 1 if (keystatus[0x3f]) //F5 { // keystatus[0x3f] = 0; @@ -2492,7 +2702,7 @@ void overheadeditor(void) keystatus[0x41] = 0; for (i=0; i= 16384) { i = pointhighlight-16384; - Bsprintf(buffer,"Sprite (%d) Hi-tag: ",i); - sprite[i].hitag = getnumber16(buffer,sprite[i].hitag,65536L,0); + Bsprintf(buffer, "Sprite (%d) Hi-tag: ", i); + sprite[i].hitag = getnumber16(buffer, sprite[i].hitag, BTAG_MAX, 0); } else if (linehighlight >= 0) { i = linehighlight; - Bsprintf(buffer,"Wall (%d) Hi-tag: ",i); - wall[i].hitag = getnumber16(buffer,wall[i].hitag,65536L,0); + Bsprintf(buffer, "Wall (%d) Hi-tag: ", i); + wall[i].hitag = getnumber16(buffer, wall[i].hitag, BTAG_MAX, 0); } } else { for (i=0; i= 16384) + if (!eitherCTRL) { - i = pointhighlight-16384; - Bsprintf(buffer,"Sprite (%d) Status list: ",i); - changespritestat(i,getnumber16(buffer,sprite[i].statnum,65536L,0)); + if (pointhighlight >= 16384) + { + i = pointhighlight-16384; + Bsprintf(buffer, "Sprite (%d) Status list: ", i); + changespritestat(i, getnumber16(buffer, sprite[i].statnum, MAXSTATUS-1, 0)); // clearmidstatbar16(); // showspritedata((int16_t)i); + // printmessage16(""); + } + } + else if (highlightsectorcnt > 0 && newnumwalls < 0&&0) + { + ////////// YAX ////////// + static const char *cfs[2] = {"ceiling", "floor"}; + + int32_t cf, thez; + + cf = ask_above_or_below(); + if (cf==-1) + goto end_yax; + + thez = YAX_SECTORFLD(highlightsector[0],z, cf); + for (i=0; i= 0) + { + message("Sector %d's %s is already extended", highlightsector[i], cfs[cf]); + goto end_yax; + } + + if (i==0) + continue; + + if (YAX_SECTORFLD(highlightsector[i],z, cf) != thez) + { + message("All sectors must have the same %s height", cfs[cf]); + goto end_yax; + } + if ((YAX_SECTORFLD(highlightsector[i],stat, cf)&2)!=0) + { + message("Sector %ss must not be sloped", cfs[cf]); + goto end_yax; + } + } + + m = numwalls; + Bmemset(visited, 0, sizeof(visited)); + // construct! + for (i=0; i highlightx2) swaplong(&highlightx1, &highlightx2); if (highlighty1 > highlighty2) swaplong(&highlighty1, &highlighty2); - if (eitherCTRL) + // Ctrl+RShift: select all wall-points of highlighted wall's loop: + if (eitherCTRL && highlightx1==highlightx2 && highlighty1==highlighty2) { Bmemset(show2dwall, 0, sizeof(show2dwall)); Bmemset(show2dsprite, 0, sizeof(show2dsprite)); - if ((linehighlight >= 0) && (linehighlight < MAXWALLS)) + if (linehighlight >= 0 && linehighlight < MAXWALLS) { i = linehighlight; do @@ -2666,6 +2987,7 @@ void overheadeditor(void) else { int32_t add=keystatus[0x28], sub=(!add && keystatus[0x27]), setop=(add||sub); + int32_t tx, ty, onlySprites=eitherCTRL; if (!setop) { @@ -2674,19 +2996,81 @@ void overheadeditor(void) } for (i=0; i= highlightx1 && wall[i].x <= highlightx2 && - wall[i].y >= highlighty1 && wall[i].y <= highlighty2) + { + if (onlySprites) + break; + + if (!m32_sideview) + { + tx = wall[i].x; + ty = wall[i].y; + wall[i].cstat &= ~(1<<14); + } + else + { + screencoords(&tx,&ty, wall[i].x-pos.x,wall[i].y-pos.y, zoom); + ty += getscreenvdisp( + getflorzofslope(sectorofwall(i), wall[i].x,wall[i].y)-pos.z, zoom); + tx += halfxdim16; + ty += midydim16; + } + + if (tx >= highlightx1 && tx <= highlightx2 && + ty >= highlighty1 && ty <= highlighty2) { if (!sub) show2dwall[i>>3] |= (1<<(i&7)); else if (sub) show2dwall[i>>3] &= ~(1<<(i&7)); } + } + + if (m32_sideview && !onlySprites) + { + // also select walls that would be dragged but + // maybe were missed +#if 1 + for (i=0; i>3]&(1<<(i&7))) + { + //N^2...ugh + for (j=0; j>3] |= (1<<(j&7)); + } +#else + for (i=0; i>3]&(1<<(i&7))) + dragpoint(i, wall[i].x, wall[i].y); + for (i=0; i>3] |= (1<<(i&7)); + wall[i].cstat &= ~(1<<14); + } +#endif + } for (i=0; i= highlightx1 && sprite[i].x <= highlightx2 && - sprite[i].y >= highlighty1 && sprite[i].y <= highlighty2) + { + if (sprite[i].statnum == MAXSTATUS) + continue; + + if (!m32_sideview) + { + tx = sprite[i].x; + ty = sprite[i].y; + } + else + { + screencoords(&tx,&ty, sprite[i].x-pos.x,sprite[i].y-pos.y, zoom); + ty += getscreenvdisp(sprite[i].z-pos.z, zoom); + tx += halfxdim16; + ty += midydim16; + } + + if (tx >= highlightx1 && tx <= highlightx2 && + ty >= highlighty1 && ty <= highlighty2) { if (!sub) { @@ -2696,6 +3080,7 @@ void overheadeditor(void) else show2dsprite[i>>3] &= ~(1<<(i&7)); } + } update_highlight(); } @@ -2709,14 +3094,17 @@ void overheadeditor(void) { if (highlightsectorcnt == 0) { - highlightx2 = searchx, highlighty2 = searchy; - ydim16 = ydim-STATUS2DSIZ2; - begindrawing(); //{{{ - drawline16(highlightx2,highlighty1, highlightx1,highlighty1, editorcolors[10]); - drawline16(highlightx2,highlighty2, highlightx1,highlighty2, editorcolors[10]); - drawline16(highlightx1,highlighty2, highlightx1,highlighty1, editorcolors[10]); - drawline16(highlightx2,highlighty2, highlightx2,highlighty1, editorcolors[10]); - enddrawing(); //}}} + if (!eitherCTRL) + { + int32_t xx[] = { highlightx1, highlightx1, searchx, searchx, highlightx1 }; + int32_t yy[] = { highlighty1, searchy, searchy, highlighty1, highlighty1 }; + + highlightx2 = searchx; + highlighty2 = searchy; + ydim16 = ydim-STATUS2DSIZ2; + + plotlines2d(xx, yy, 5, editorcolors[10]); + } } else { @@ -2729,7 +3117,7 @@ void overheadeditor(void) { if (wall[j].nextwall >= 0) checksectorpointer(wall[j].nextwall,wall[j].nextsector); - didmakered |= !!checksectorpointer((int16_t)j,highlightsector[i]); + didmakered |= !!checksectorpointer(j, highlightsector[i]); if (!didmakered) { @@ -2742,166 +3130,96 @@ void overheadeditor(void) if (!didmakered && !hadouterpoint && newnumwalls<0) { - char blackcol=editorcolors[0], greycol=whitecol-25, *cp; - // fade the screen to have the user's attention - begindrawing(); - cp = (char *)frameplace; - for (i=0; i>3,1); + int16_t ignore, refsect; + int32_t n; - if (!visitedwall) - { - message("out of memory!"); - break; - } - - for (i=0; i=0 || (visitedwall[j>>3]&(1<<(j&7)))) + k = trace_loop(j, visited, &ignore, &refsect); + if (k == 0) continue; - - n=2*tmpnumwalls; // simple inf loop check - refwall = j; - k = numwalls; - - ignore = 0; - refsect = -1; - updatesectorexclude(wall[j].x, wall[j].y, &refsect, hlsectorbitmap); - if (refsect<0) - goto outtathis; - - do + else if (k < 0) { - if (j!=refwall && visitedwall[j>>3]&(1<<(j&7))) - ignore = 1; - visitedwall[j>>3] |= (1<<(j&7)); + i = highlightsectorcnt; + break; // outer loop too + } - if (inside(wall[j].x, wall[j].y, refsect)!=1) - ignore = 1; + if (ignore) + continue; + + wall[k-1].point2 = numwalls; // close the loop + newnumwalls = k; + n = (newnumwalls-numwalls); // number of walls in just constructed loop - if (!ignore) + if (clockdir(numwalls)==0) + { + int16_t begwalltomove = sector[refsect].wallptr+sector[refsect].wallnum; + + flipwalls(numwalls, newnumwalls); + + sector[refsect].wallnum += n; + if (refsect != numsectors-1) { - if (k>=MAXWALLS) + walltype *tmpwall = Bmalloc(n * sizeof(walltype)); + + if (!tmpwall) { - message("Wall limits exceeded while tracing outer loop."); - goto outtathis; + message("out of memory!"); + ExtUnInit(); + uninitsystem(); + exit(1); } - Bmemcpy(&wall[k], &wall[j], sizeof(walltype)); - wall[k].point2 = k+1; - wall[k].nextsector = wall[k].nextwall = wall[k].extra = -1; - k++; - } - - j = wall[j].point2; - n--; - - while (wall[j].nextwall>=0 && n>0) - { - j = wall[wall[j].nextwall].point2; -// if (j!=refwall && (visitedwall[j>>3]&(1<<(j&7)))) -// ignore = 1; -// visitedwall[j>>3] |= (1<<(j&7)); - n--; - } - } - while (j!=refwall && n>0); - - if (j!=refwall) - { - message("internal error while tracing outer loop: didn't reach refwall"); - goto outtathis; - } - - if (!ignore) - { - wall[k-1].point2 = numwalls; // close the loop - newnumwalls = k; - n = (newnumwalls-numwalls); // number of walls in just constructed loop - - if (clockdir(numwalls)==0) - { - int16_t begwalltomove = sector[refsect].wallptr+sector[refsect].wallnum; - - flipwalls(numwalls, newnumwalls); - - sector[refsect].wallnum += n; - if (refsect != numsectors-1) + for (m=0; m= begwalltomove) - wall[m].nextwall += n; - } - for (m=refsect+1; m= begwalltomove) + wall[m].nextwall += n; } - numwalls = newnumwalls; - newnumwalls = -1; + for (m=refsect+1; m highlightx2) - swaplong(&highlightx1, &highlightx2); - if (highlighty1 > highlighty2) - swaplong(&highlighty1, &highlighty2); + if (!pointsel) + { + if (highlightx1 > highlightx2) + swaplong(&highlightx1, &highlightx2); + if (highlighty1 > highlighty2) + swaplong(&highlighty1, &highlighty2); + } if (!setop) Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap)); for (i=0; i highlightx2) bad = 1; - if (wall[j].y < highlighty1) bad = 1; - if (wall[j].y > highlighty2) bad = 1; - if (bad == 1) break; + bad = (inside_editor(&pos, searchx,searchy, zoom, highlightx2, highlighty2, i)!=1); } + else + { + bad = 0; + for (WALLS_OF_SECTOR(i, j)) + { + if (!m32_sideview) + { + tx = wall[j].x; + ty = wall[j].y; + } + else + { + screencoords(&tx,&ty, wall[j].x-pos.x,wall[j].y-pos.y, zoom); + ty += getscreenvdisp(getflorzofslope(i, wall[j].x,wall[j].y)-pos.z, zoom); + tx += halfxdim16; + ty += midydim16; + } + + if (tx < highlightx1 || tx > highlightx2) bad = 1; + if (ty < highlighty1 || ty > highlighty2) bad = 1; + if (bad == 1) break; + } + } + if (bad == 0) { if (sub) @@ -2942,7 +3286,7 @@ outtathis: { if (wall[j].nextwall >= 0) checksectorpointer(wall[j].nextwall,wall[j].nextsector); - checksectorpointer((int16_t)j, i); + checksectorpointer(j, i); } } else @@ -2952,20 +3296,19 @@ outtathis: update_highlightsector(); ovh_whiteoutgrab(); + +// if (highlightsectorcnt>0) +// printmessage16("Total selected sectors: %d", highlightsectorcnt); } } } if (((bstatus&1) < (oldmousebstatus&1)) && highlightsectorcnt < 0) //after dragging { - int32_t wallsdrawn = newnumwalls-numwalls, runi; + int32_t runi; - if (newnumwalls != -1) - { - newnumwalls = -1; - Bmemcpy(&wall[MAXWALLS-wallsdrawn],&wall[numwalls],sizeof(walltype) * wallsdrawn); - } - else wallsdrawn = -1; + if (backup_drawn_walls(0)) + goto end_after_dragging; j = 1; if (highlightcnt > 0) @@ -2979,35 +3322,12 @@ outtathis: if (j == 0) { for (i=0; i=0) - { - sprite[j].z = max(sprite[j].z, getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint); - sprite[j].z = min(sprite[j].z, getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)); - } - } - } + updatesprite1(highlight[i]&16383); } else if ((pointhighlight&0xc000) == 16384) { - j = (pointhighlight&16383); - - setsprite(j,(vec3_t *)&sprite[j]); - - tempint = ((tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<2); - - if (sprite[j].sectnum>=0) - { - sprite[j].z = max(sprite[j].z, getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint); - sprite[j].z = min(sprite[j].z, getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)); - } + updatesprite1(pointhighlight&16383); } if ((pointhighlight&0xc000) == 0) @@ -3024,25 +3344,25 @@ outtathis: for (runi=0; runi<2; runi++) for (i=numwalls-1; i>=0; i--) //delete points { - if (wall[i].x == POINT2(i).x && wall[i].y == POINT2(i).y) - if (sector[sectorofwall((int16_t)i)].wallnum > 3) - if (sector[sectorofwall(wall[i].point2)].wallnum > 3) - { - int32_t b = (wall[i].nextwall == -1 || - (sector[sectorofwall(wall[i].nextwall)].wallnum > 3 && - sector[sectorofwall(NEXTWALL(i).point2)].wallnum > 3)); - if (runi==0 && !b) - { - printmessage16("Invalid operation, delete or join sector instead."); - goto SKIP; - } - else if (runi==1 && b) - { - deletepoint((int16_t)i); - printmessage16("Point deleted."); - asksave = 1; - } - } + if (wall[i].x == POINT2(i).x && wall[i].y == POINT2(i).y + && sector[sectorofwall(i)].wallnum > 3 + && sector[sectorofwall(wall[i].point2)].wallnum > 3) + { + int32_t b = (wall[i].nextwall == -1 || + (sector[sectorofwall(wall[i].nextwall)].wallnum > 3 && + sector[sectorofwall(NEXTWALL(i).point2)].wallnum > 3)); + if (runi==0 && !b) + { + printmessage16("Invalid operation, delete or join sector instead."); + goto end_after_dragging; + } + else if (runi==1 && b) + { + deletepoint(i); + printmessage16("Point deleted."); + asksave = 1; + } + } } for (i=0; i 0) //drag points { if (highlightsectorcnt > 0) @@ -3078,13 +3392,13 @@ SKIP: // updatesector(mousxplc,mousyplc,&cursectorhighlight); cursectorhighlight = -1; for (i=0; i= 0) && (cursectorhighlight < numsectors)) + if (cursectorhighlight >= 0 && cursectorhighlight < numsectors) { // for (i=0; i (oldmousebstatus&1)) pointhighlight = getpointhighlight(mousxplc, mousyplc, pointhighlight); @@ -3203,7 +3517,16 @@ SKIP: else { if ((pointhighlight&0xc000) == 0) + { + if (newnumwalls >= numwalls && + wall[pointhighlight].x==firstx && wall[pointhighlight].y==firsty) + { + printmessage16("Can't drag point where drawing started."); + goto end_point_dragging; + } + dragpoint(pointhighlight,dax,day); + } else if ((pointhighlight&0xc000) == 16384) { int32_t daspr=pointhighlight&16383, osec=sprite[daspr].sectnum; @@ -3216,7 +3539,7 @@ SKIP: if (setsprite(daspr, &vec) == -1 && osec>=0) Bmemcpy(&sprite[daspr], &ovec, sizeof(vec3_t)); #if 0 - daz = ((tilesizy[sprite[daspr].picnum]*sprite[daspr].yrepeat)<<2); + daz = spriteheight(daspr, NULL); for (i=0; i= 0) + keystatus[0x24] = 0; + + if (newnumwalls >= 0) { - joinsector[1] = -1; - - for (i=0; i= endwall && i != joinsector[0]) - { - _printmessage16("Join non-adjacent sectors? (Y/N)"); - showframe(1); - bflushchars(); ch = 0; - while (keystatus[1] == 0) - { - if (handleevents()) - quitevent = 0; - - idle(); - - ch = bgetchar(); - - if (ch == 'Y' || ch == 'y') - { - joinsector[1] = i; - break; - } - else if (ch == 'N' || ch == 'n' || ch == 13 || ch == ' ') - { - joinsector[1] = joinsector[0]; - break; - } - } - break; - } - else - { - joinsector[1] = i; - break; - } - } - } - - if ((joinsector[1] >= 0) && (joinsector[0] != joinsector[1])) - { - newnumwalls = numwalls; - - for (k=0; k<2; k++) - { - for (WALLS_OF_SECTOR(joinsector[k], j)) - { - if (wall[j].cstat == 255) - continue; - joinsectnum = k; - if (wall[j].nextsector == joinsector[1-joinsectnum]) - { - wall[j].cstat = 255; - continue; - } - - i = j; - m = newnumwalls; - do - { - Bmemcpy(&wall[newnumwalls],&wall[i],sizeof(walltype)); - wall[newnumwalls].point2 = newnumwalls+1; - newnumwalls++; - wall[i].cstat = 255; - - i = wall[i].point2; - if (wall[i].nextsector == joinsector[1-joinsectnum]) - { - i = NEXTWALL(i).point2; - joinsectnum = 1 - joinsectnum; - } - } - while ((wall[i].cstat != 255) && (wall[i].nextsector != joinsector[1-joinsectnum])); - wall[newnumwalls-1].point2 = m; - } - } - - if (newnumwalls > numwalls) - { - Bmemcpy(§or[numsectors],§or[joinsector[0]],sizeof(sectortype)); - sector[numsectors].wallptr = numwalls; - sector[numsectors].wallnum = newnumwalls-numwalls; - - //fix sprites - for (i=0; i<2; i++) - { - j = headspritesect[joinsector[i]]; - while (j != -1) - { - k = nextspritesect[j]; - changespritesect(j,numsectors); - j = k; - } - } - - numsectors++; - - for (i=numwalls; i= 0) - { - NEXTWALL(i).nextwall = i; - NEXTWALL(i).nextsector = numsectors-1; - } - } - - numwalls = newnumwalls; - newnumwalls = -1; - - for (k=0; k<2; k++) - { - for (WALLS_OF_SECTOR(joinsector[k], j)) - { - wall[j].nextwall = -1; - wall[j].nextsector = -1; - } - } - - deletesector((int16_t)joinsector[0]); - if (joinsector[0] < joinsector[1]) - joinsector[1]--; - deletesector((int16_t)joinsector[1]); - printmessage16("Sectors joined."); - } - } - else - printmessage16("No sectors joined."); - - joinsector[0] = -1; + printmessage16("Can't join sectors while editing."); + goto end_join_sectors; } - else + + if (joinsector[0] < 0) { joinsector[0] = -1; for (i=0; i= MAXWALLS + M32_FIXME_WALLS) + { + message("Joining sectors failed: not enough space beyond wall[]"); + joinsector[0] = -1; + newnumwalls = -1; + + for (i=0; i0 && ((wall[i].cstat & (1<<14))==0) + && (wall[i].nextsector != joinsector[1-joink])); + + wall[newnumwalls-1].point2 = m; + + if (loopnum==0) + { + printmessage16("internal error while joining sectors: infloop!"); + newnumwalls = -1; + } + } + } + + if (newnumwalls > numwalls) + { + Bmemcpy(§or[numsectors], §or[joinsector[0]], sizeof(sectortype)); + sector[numsectors].wallptr = numwalls; + sector[numsectors].wallnum = newnumwalls-numwalls; + + //fix sprites + for (i=0; i<2; i++) + { + j = headspritesect[joinsector[i]]; + while (j != -1) + { + k = nextspritesect[j]; + changespritesect(j, numsectors); + j = k; + } + } + + numsectors++; + + for (i=numwalls; i= 0) + { + NEXTWALL(i).nextwall = i; + NEXTWALL(i).nextsector = numsectors-1; + } + } + + numwalls = newnumwalls; + newnumwalls = -1; + + for (k=0; k<2; k++) + for (WALLS_OF_SECTOR(joinsector[k], j)) + wall[j].nextwall = wall[j].nextsector = -1; + + deletesector(joinsector[0]); + if (joinsector[0] < joinsector[1]) + joinsector[1]--; + deletesector(joinsector[1]); + + printmessage16("Sectors joined."); + asksave = 1; + } + + joinsector[0] = -1; } - keystatus[0x24] = 0; } +end_join_sectors: // PK for (i=0x02; i<=0x0b; i++) // keys '1' to '0' on the upper row @@ -3602,11 +3944,15 @@ SKIP: if (eitherALT && keystatus[0x1f]) //ALT-S { + keystatus[0x1f] = 0; + if (linehighlight >= 0 && wall[linehighlight].nextwall == -1) { - if ((newnumwalls = whitelinescan(linehighlight)) < numwalls) + newnumwalls = whitelinescan(linehighlight); + if (newnumwalls < numwalls) { printmessage16("Can't make a sector out there."); + newnumwalls = -1; } else if (newnumwalls > MAXWALLS) { @@ -3620,19 +3966,22 @@ SKIP: NEXTWALL(i).nextwall = i; NEXTWALL(i).nextsector = numsectors; } + numwalls = newnumwalls; newnumwalls = -1; numsectors++; + printmessage16("Inner loop made into new sector."); } } - keystatus[0x1f] = 0; } else if (keystatus[0x1f]) //S { + keystatus[0x1f] = 0; + sucksect = -1; for (i=0; i 0) locktogrid(&dax, &day); - i = insertsprite(sucksect,0); - sprite[i].x = dax, sprite[i].y = day; - sprite[i].cstat = defaultspritecstat; - sprite[i].shade = 0; - sprite[i].pal = 0; - sprite[i].xrepeat = 64, sprite[i].yrepeat = 64; - sprite[i].xoffset = 0, sprite[i].yoffset = 0; - sprite[i].ang = 1536; - sprite[i].xvel = 0; sprite[i].yvel = 0; sprite[i].zvel = 0; - sprite[i].owner = -1; - sprite[i].clipdist = 32; - sprite[i].lotag = 0; - sprite[i].hitag = 0; - sprite[i].extra = -1; + i = insert_sprite_common(sucksect, dax, day); - sprite[i].z = getflorzofslope(sucksect,dax,day); - if ((sprite[i].cstat&128) != 0) - sprite[i].z -= ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); - - Bmemset(localartfreq, 0, sizeof(localartfreq)); - for (k=0; k localartfreq[j]) - j = k; - - if (localartfreq[j] > 0) - sprite[i].picnum = j; + if (i < 0) + printmessage16("Couldn't insert sprite."); else - sprite[i].picnum = 0; + { + sprite[i].z = getflorzofslope(sucksect,dax,day); +// if (sprite[i].cstat&128) +// sprite[i].z -= spriteheight(i, NULL)>>1; // PK - if (prefixarg) - { - sprite[i].picnum = prefixarg; - sprite[i].xrepeat = sprite[i].yrepeat = 48; - prefixarg = 0; - } - else if (somethingintab == 3) - { - sprite[i].picnum = temppicnum; - if (tilesizx[temppicnum] <= 0 || tilesizy[temppicnum] <= 0) + if (prefixarg) { - j = 0; - for (k=0; k 0 && tilesizy[k] > 0) - { - j = k; - break; - } - sprite[i].picnum = j; + sprite[i].picnum = prefixarg; + sprite[i].xrepeat = sprite[i].yrepeat = 48; + prefixarg = 0; } - sprite[i].shade = tempshade; - sprite[i].pal = temppal; - sprite[i].xrepeat = max(tempxrepeat, 1); - sprite[i].yrepeat = max(tempyrepeat, 1); - sprite[i].cstat = tempcstat; + else if (somethingintab == 3) + { + sprite[i].picnum = temppicnum; + if (tilesizx[temppicnum] <= 0 || tilesizy[temppicnum] <= 0) + { + j = 0; + for (k=0; k 0 && tilesizy[k] > 0) + { + j = k; + break; + } + sprite[i].picnum = j; + } + sprite[i].shade = tempshade; + sprite[i].pal = temppal; + sprite[i].xrepeat = max(tempxrepeat, 1); + sprite[i].yrepeat = max(tempyrepeat, 1); + sprite[i].cstat = tempcstat; + } + + if (tilesizy[sprite[i].picnum] >= 32) + sprite[i].cstat |= 1; + + correct_sprite_yoffset(i); + + printmessage16("Sprite inserted."); + updatenumsprites(); + asksave = 1; + + VM_OnEvent(EVENT_INSERTSPRITE2D, i); } - - if (tilesizy[sprite[i].picnum] >= 32) - sprite[i].cstat |= 1; - - printmessage16("Sprite inserted."); - updatenumsprites(); - asksave = 1; - - VM_OnEvent(EVENT_INSERTSPRITE2D, i); } - - keystatus[0x1f] = 0; } if (keystatus[0x2e]) // C (make circle of points) @@ -3754,7 +4081,7 @@ SKIP: if (tempint2 != 0) { - int32_t ps = 2; // pointsize + int32_t ps = 2, goodtogo; // pointsize centerx = ((x1+x2) + scale(y1-y2,tempint1,tempint2))>>1; centery = ((y1+y2) + scale(x2-x1,tempint1,tempint2))>>1; @@ -3832,63 +4159,30 @@ SKIP: } } - goodtogo = 1; // Checking limits... - if (bad > 0) - { - if (newnumwalls < numwalls) - { - // ---why MAXWALLS-2? wall[MAXWALLS-1] would be inserted, but would - // need to draw end of wall trail in wall[MAXWALLS]!--- - - // for MAXWALLS-1 we need extra space at the end of wall[] - if (numwalls >= MAXWALLS-1) - { - goodtogo = 0; - printmessage16("Can't start sector drawing: wall limit reached."); - } - } - else - { - //if not back to first point - if (firstx != mousxplc || firsty != mousyplc) //nextpoint - { - if (newnumwalls>=MAXWALLS) - { - goodtogo = 0; - printmessage16("Inserting another point would exceed wall limit."); - } - } - - //if not split and back to first point - if ((split == 0) && (firstx == mousxplc) && (firsty == mousyplc) && (newnumwalls >= numwalls+3)) - { - if (suckwall == -1) //if no connections to other sectors - { /* No problem... */ } - else - { - if (newnumwalls>=MAXWALLS) // still too optimistic since we can have more than one new red wall - { - goodtogo = 0; - printmessage16("Closing wall drawing would exceed wall limit."); - } - } - } -// else if (split==1) {} // handled there - } - } - - if (bad > 0 && goodtogo) //Space + if (bad > 0) //Space { if (newnumwalls < numwalls) // starting wall drawing { + if (numwalls >= MAXWALLS-1) + { + // whatever we do, we will need at least two new walls + printmessage16("Can't start sector drawing: wall limit reached."); + goto end_space_handling; + } + + if (numsectors >= MAXSECTORS) + { + printmessage16("Can't start sector drawing: sector limit reached."); + goto end_space_handling; + } + firstx = mousxplc; firsty = mousyplc; //Make first point newnumwalls = numwalls; suckwall = -1; split = 0; - //clearbufbyte(&wall[newnumwalls],sizeof(walltype),0L); - Bmemset(&wall[newnumwalls],0,sizeof(walltype)); + Bmemset(&wall[newnumwalls], 0, sizeof(walltype)); wall[newnumwalls].extra = -1; wall[newnumwalls].x = mousxplc; @@ -3901,14 +4195,21 @@ SKIP: suckwall = i; wall[newnumwalls].point2 = newnumwalls+1; - printmessage16("Sector drawing started."); newnumwalls++; + + printmessage16("Sector drawing started."); } - else + else // 2nd point and up... { //if not back to first point if (firstx != mousxplc || firsty != mousyplc) //nextpoint { + if (newnumwalls>=MAXWALLS) + { + printmessage16("Inserting another point would exceed wall limit."); + goto end_space_handling; + } + j = 0; for (i=numwalls; i>1; day = (wall[numwalls].y+mousyplc)>>1; for (i=0; i= 0) - if (POINT2(k).x != mousxplc || POINT2(k).y != mousyplc) - if (wall[lastwall(k)].x != mousxplc || wall[lastwall(k)].y != mousyplc) - { - split = 1; - splitsect = i; - splitstartwall = m; - break; - } - } + //check if first point at point of sector + m = -1; + for (WALLS_OF_SECTOR(i, k)) + if (wall[k].x==wall[numwalls].x && wall[k].y==wall[numwalls].y) + { + m = k; + break; + } + + // if the second insertion is not on a neighboring point of the first one... + if (m>=0 && (POINT2(k).x != mousxplc || POINT2(k).y != mousyplc)) + if (wall[lastwall(k)].x != mousxplc || wall[lastwall(k)].y != mousyplc) + { + split = 1; + splitsect = i; + splitstartwall = m; + break; + } + } } //make new point @@ -3954,10 +4257,13 @@ SKIP: { if (wall[i].nextwall >= 0) { + int32_t lastwalx = wall[newnumwalls-1].x; + int32_t lastwaly = wall[newnumwalls-1].y; + if (wall[i].x == mousxplc && wall[i].y == mousyplc) - if (POINT2(i).x == wall[newnumwalls-1].x && POINT2(i).y == wall[newnumwalls-1].y) + if (POINT2(i).x == lastwalx && POINT2(i).y == lastwaly) bad = 1; - if (wall[i].x == wall[newnumwalls-1].x && wall[i].y == wall[newnumwalls-1].y) + if (wall[i].x == lastwalx && wall[i].y == lastwaly) if (POINT2(i).x == mousxplc && POINT2(i).y == mousyplc) bad = 1; } @@ -3965,8 +4271,7 @@ SKIP: if (bad == 0) { - //clearbufbyte(&wall[newnumwalls],sizeof(walltype),0L); - Bmemset(&wall[newnumwalls],0,sizeof(walltype)); + Bmemset(&wall[newnumwalls], 0, sizeof(walltype)); wall[newnumwalls].extra = -1; wall[newnumwalls].x = mousxplc; @@ -3984,12 +4289,16 @@ SKIP: else { printmessage16("You can't draw new lines over red lines."); + goto end_space_handling; } } } + ////////// newnumwalls is at most MAXWALLS here ////////// + //if not split and back to first point - if ((split == 0) && (firstx == mousxplc) && (firsty == mousyplc) && (newnumwalls >= numwalls+3)) + if (!split && newnumwalls >= numwalls+3 + && firstx==mousxplc && firsty==mousyplc) { wall[newnumwalls-1].point2 = numwalls; @@ -3997,8 +4306,22 @@ SKIP: { k = -1; for (i=0; i=suckwall; i--) - Bmemcpy(&wall[i+j],&wall[i],sizeof(walltype)); + Bmemcpy(&wall[i+j], &wall[i], sizeof(walltype)); for (i=0; i MAXWALLS) - { - if (bad==0) - printmessage16("Splitting sector would exceed wall limit."); - else - printmessage16("Joining sector loops would exceed wall limit."); - newnumwalls--; - break; - } + splitendwall = k; + doSectorSplit = (loopnumofsector(splitsect,splitstartwall) + == loopnumofsector(splitsect,splitendwall)); - if (bad == 0) - { - //SPLIT IT! - //Split splitsect given: startwall, - // new points: numwalls to newnumwalls-2 + if (expectedNumwalls > MAXWALLS) + { + printmessage16("%s would exceed wall limit.", bad==0 ? + "Splitting sector" : "Joining sector loops"); + newnumwalls--; + break; + } - splitendwall = k; - newnumwalls--; //first fix up the new walls - for (i=numwalls; inumwalls; j--) - { - Bmemcpy(&wall[danumwalls],&wall[j],sizeof(walltype)); - wall[danumwalls].nextwall = -1; - wall[danumwalls].nextsector = -1; - wall[danumwalls].point2 = danumwalls+1; - danumwalls++; - } - m = splitstartwall; //copy rest of loop next - while (m != splitendwall) - { - Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype)); - wall[danumwalls].point2 = danumwalls+1; - danumwalls++; - m = wall[m].point2; - } - wall[danumwalls-1].point2 = secondstartwall; + //Add other loops for 1st sector + i = loopnum = loopnumofsector(splitsect,splitstartwall); - //Add other loops for 2nd sector - loopnum = loopnumofsector(splitsect,splitstartwall); - i = loopnum; - for (j=startwall; j<=endwall; j++) - { - k = loopnumofsector(splitsect,(int16_t)j); - if ((k != i) && (k != loopnum)) - { - i = k; - if (loopinside(wall[j].x,wall[j].y,secondstartwall) == 1) - { - m = j; //copy loop - k = danumwalls; - do - { - Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype)); - wall[danumwalls].point2 = danumwalls+1; - danumwalls++; - m = wall[m].point2; - } - while (m != j); - wall[danumwalls-1].point2 = k; - } - } - } + for (j=startwall; j<=endwall; j++) + { + k = loopnumofsector(splitsect,j); + if (k == i) + continue; - //fix all next pointers on old sector line - for (j=numwalls; j= 0) - { - NEXTWALL(j).nextwall = j; - if (j < secondstartwall) - NEXTWALL(j).nextsector = numsectors; - else - NEXTWALL(j).nextsector = numsectors+1; - } - } - //set all next pointers on split - for (j=numwalls; j= 0) - checksectorpointer(wall[j].nextwall,wall[j].nextsector); - checksectorpointer((int16_t)j,sectorofwall((int16_t)j)); - } + //copy split points for other sector backwards + for (j=newnumwalls; j>numwalls; j--) + { + Bmemcpy(&wall[danumwalls], &wall[j], sizeof(walltype)); + wall[danumwalls].nextwall = -1; + wall[danumwalls].nextsector = -1; + wall[danumwalls].point2 = danumwalls+1; + danumwalls++; + } - //k now safe to use as temp + m = splitstartwall; //copy rest of loop next - for (m=numsectors-2; m= 0) + { + NEXTWALL(j).nextwall = j; + + if (!doSectorSplit || j < secondstartwall) + NEXTWALL(j).nextsector = numsectors; else + NEXTWALL(j).nextsector = numsectors+1; + } + } + + if (doSectorSplit) + { + //set all next pointers on split + for (j=numwalls; j= 0) + checksectorpointer(wall[j].nextwall, wall[j].nextsector); + checksectorpointer(j, sectorofwall(j)); + } + + //k now safe to use as temp +#if 0 + if (doSectorSplit) + for (m=numsectors-2; mnumwalls; j--) - { - Bmemcpy(&wall[danumwalls],&wall[j],sizeof(walltype)); - wall[danumwalls].nextwall = -1; - wall[danumwalls].nextsector = -1; - wall[danumwalls].point2 = danumwalls+1; - danumwalls++; - } - - m = splitstartwall; //copy rest of loop next - do - { - Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype)); - wall[danumwalls].point2 = danumwalls+1; - danumwalls++; - m = wall[m].point2; - } - while (m != splitstartwall); - wall[danumwalls-1].point2 = numwalls; - - //Add other loops to sector - loopnum = loopnumofsector(splitsect,splitstartwall); - i = loopnum; - for (j=startwall; j<=endwall; j++) - { - k = loopnumofsector(splitsect,(int16_t)j); - if ((k != i) && (k != loopnumofsector(splitsect,splitstartwall)) && (k != loopnumofsector(splitsect,splitendwall))) - { - i = k; - m = j; k = danumwalls; //copy loop - do - { - Bmemcpy(&wall[danumwalls],&wall[m],sizeof(walltype)); - wall[danumwalls].point2 = danumwalls+1; - danumwalls++; - m = wall[m].point2; - } - while (m != j); - wall[danumwalls-1].point2 = k; - } - } - - //fix all next pointers on old sector line - for (j=numwalls; j= 0) - { - NEXTWALL(j).nextwall = j; - NEXTWALL(j).nextsector = numsectors; - } - } - - //copy sector attributes & fix wall pointers - Bmemcpy(§or[numsectors],§or[splitsect],sizeof(sectortype)); - sector[numsectors].wallptr = numwalls; - sector[numsectors].wallnum = danumwalls-numwalls; - - //fix sprites - j = headspritesect[splitsect]; - while (j != -1) - { - k = nextspritesect[j]; - changespritesect(j,numsectors); - j = k; - } - - numsectors++; - - //Back of number of walls of new sector for later - k = danumwalls-numwalls; - - //clear out old sector's next pointers for clean deletesector - numwalls = danumwalls; - for (j=startwall; j<=endwall; j++) - { - wall[j].nextwall = -1; - wall[j].nextsector = -1; - } - deletesector(splitsect); - - //Check pointers - for (j=numwalls-k; j= 0) - checksectorpointer(wall[j].nextwall,wall[j].nextsector); - checksectorpointer((int16_t)j,numsectors-1); - } - - newnumwalls = -1; - printmessage16("Loops joined."); - break; + k = nextspritesect[j]; + setsprite(j, (vec3_t *)&sprite[j]); + j = k; } } +#endif + + if (numwalls==expectedNumwalls) + { + message("%s", doSectorSplit ? "Sector split." : "Loops joined."); + } + else + { + message("%s WARNING: CREATED %d MORE WALLS THAN EXPECTED!", + doSectorSplit ? "Sector split." : "Loops joined.", + expectedNumwalls-numwalls); + // this would display 'num* out of bounds' but this corruption + // is almost as bad... + if (numcorruptthings < MAXCORRUPTTHINGS) + corruptthings[numcorruptthings++] = 0; + corruptlevel = 5; + } + + if (0) + { + split_not_enough_walls: + message("%s failed: not enough space beyond wall[]", + doSectorSplit ? "Splitting sectors" : "Joining loops"); + } + + newnumwalls = -1; } } } +end_space_handling: if (keystatus[0x1c]) //Left Enter { keystatus[0x1c] = 0; - if (keystatus[0x2a]&keystatus[0x1d]) + if (keystatus[0x2a] && keystatus[0x1d]) // LCtrl+LShift { printmessage16("CHECKING ALL POINTERS!"); for (i=0; i= numwalls) + if (keystatus[0x0e]) //Backspace { - if (newnumwalls > numwalls+1) - newnumwalls--; - else - newnumwalls = -1; + keystatus[0x0e] = 0; + + if (newnumwalls >= numwalls) + { + backspace_last = 1; + + if (newnumwalls == numwalls+1 || keystatus[0x1d]) // LCtrl: delete all newly drawn walls + newnumwalls = -1; + else + newnumwalls--; + } + else if (backspace_last==0) + { + graphicsmode += (1-2*(DOWN_BK(RUN) || keystatus[0x36]))+3; + graphicsmode %= 3; + printmessage16("2D mode textures %s", + (graphicsmode == 2)?"enabled w/ animation":graphicsmode?"enabled":"disabled"); + } } else - { - graphicsmode += (1-2*(DOWN_BK(RUN) || keystatus[0x36]))+3; - graphicsmode %= 3; - printmessage16("2D mode textures %s", - (graphicsmode == 2)?"enabled w/ animation":graphicsmode?"enabled":"disabled"); - } - + backspace_last = 0; } - if (keystatus[0xd3] && eitherCTRL && (numwalls >= 0)) //sector delete + if (keystatus[0xd3] && eitherCTRL && numwalls > 0) //sector delete { keystatus[0xd3] = 0; sucksect = -1; for (i=0; i= 0) - for (j=0; j= 0) + for (j=0; j=0; j--) { - for (j=highlightsectorcnt-1; j>=0; j--) - { - deletesector(highlightsector[j]); - for (k=j-1; k>=0; k--) - if (highlightsector[k] >= highlightsector[j]) - highlightsector[k]--; - } - - newnumwalls = -1; - Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap)); - highlightsectorcnt = -1; - - Bmemset(show2dwall, 0, sizeof(show2dwall)); - update_highlight(); - - printmessage16("Highlighted sectors deleted."); - k = 1; - break; + deletesector(highlightsector[j]); + for (k=j-1; k>=0; k--) + if (highlightsector[k] >= highlightsector[j]) + highlightsector[k]--; } - if (k == 0) - { - deletesector((int16_t)i); - Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap)); - highlightsectorcnt = -1; - Bmemset(show2dwall, 0, sizeof(show2dwall)); - update_highlight(); + printmessage16("Highlighted sectors deleted."); + k = 1; + break; + } - printmessage16("Sector deleted."); - } - newnumwalls = -1; - asksave = 1; - break; + if (k == 0) + { + deletesector(i); + printmessage16("Sector deleted."); } + + Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap)); + highlightsectorcnt = -1; + + Bmemset(show2dwall, 0, sizeof(show2dwall)); + update_highlight(); + + newnumwalls = -1; + asksave = 1; + + break; + } } if (keystatus[0xd3] && (pointhighlight >= 0)) @@ -4588,23 +4816,22 @@ SKIP: duplicate_selected_sprites(); else if (linehighlight >= 0) { - int32_t wallsdrawn = newnumwalls-numwalls; + int32_t onewnumwalls = newnumwalls; int32_t wallis2sided = (wall[linehighlight].nextwall>=0); - if (newnumwalls != -1) + if (backup_drawn_walls(0)) { - newnumwalls = -1; - Bmemcpy(&wall[MAXWALLS-wallsdrawn],&wall[numwalls],sizeof(walltype) * wallsdrawn); + message("OUT OF MEMORY!"); } - else wallsdrawn = -1; - - if (max(numwalls,newnumwalls) >= MAXWALLS-wallis2sided) + else if (max(numwalls,onewnumwalls) >= MAXWALLS-wallis2sided) + { printmessage16("Inserting point would exceed wall limit."); + } else { - getclosestpointonwall(mousxplc,mousyplc,(int32_t)linehighlight,&dax,&day); - adjustmark(&dax,&day,newnumwalls); - insertpoint(linehighlight,dax,day); + getclosestpointonwall(mousxplc,mousyplc, linehighlight, &dax,&day); + adjustmark(&dax,&day, newnumwalls); + insertpoint(linehighlight, dax,day); printmessage16("Point inserted."); j = 0; @@ -4612,15 +4839,15 @@ SKIP: for (i=numwalls-1; i>=0; i--) //delete points if (wall[i].x == POINT2(i).x && wall[i].y == POINT2(i).y) { - deletepoint((int16_t)i); + deletepoint(i); j++; } for (i=0; i=4))) SaveBoard(NULL, 0); while (keystatus[1] || keystatus[0x2e]) @@ -5002,6 +5223,7 @@ CANCEL: showframe(1); } } + clearkeys(); m32_setkeyfilter(1); @@ -5017,8 +5239,8 @@ CANCEL: for (WALLS_OF_SECTOR(highlightsector[i], j)) { if (wall[j].nextwall >= 0) - checksectorpointer(wall[j].nextwall,wall[j].nextsector); - checksectorpointer((int16_t)j,highlightsector[i]); + checksectorpointer(wall[j].nextwall, wall[j].nextsector); + checksectorpointer(j, highlightsector[i]); } } @@ -5032,7 +5254,7 @@ CANCEL: uninittimer(); uninitsystem(); clearfilenames(); - exit(0); + exit(1); } setbrightness(GAMMA_CALC,0,0); @@ -5047,9 +5269,13 @@ CANCEL: VM_OnEvent(EVENT_ENTER3DMODE, -1); } -static int32_t ask_if_sure(const char *query, int32_t quit_is_yes) +// flags: +// 1: quit_is_yes +// 2: don't clear keys on return +static int32_t ask_if_sure(const char *query, uint32_t flags) { char ch; + int32_t ret=-1; if (!query) _printmessage16("Are you sure?"); @@ -5058,13 +5284,13 @@ static int32_t ask_if_sure(const char *query, int32_t quit_is_yes) showframe(1); bflushchars(); - while ((keystatus[1]|keystatus[0x2e]) == 0) + while ((keystatus[1]|keystatus[0x2e]) == 0 && ret==-1) { if (handleevents()) { if (quitevent) { - if (quit_is_yes) + if (flags&1) return 1; else quitevent = 0; @@ -5075,14 +5301,49 @@ static int32_t ask_if_sure(const char *query, int32_t quit_is_yes) ch = bgetchar(); if (ch == 'y' || ch == 'Y') - return 1; + ret = 1; else if (ch == 'n' || ch == 'N' || ch == 13 || ch == ' ') - return 0; + ret = 0; } + if ((flags&2)==0) + clearkeys(); + + if (ret >= 0) + return ret; + return 0; } +static int32_t ask_above_or_below() +{ + char ch; + int32_t ret=-1; + + _printmessage16("Extend above (a) or below (z)?"); + + showframe(1); + bflushchars(); + + while ((keystatus[1]|keystatus[0x2e]) == 0 && ret==-1) + { + if (handleevents()) + quitevent = 0; + + idle(); + ch = bgetchar(); + + if (ch == 'a' || ch == 'A') + ret = 0; + else if (ch == 'z' || ch == 'Z') + ret = 1; + } + + clearkeys(); + + return ret; +} + // flags: 1:no ExSaveMap (backup.map) const char *SaveBoard(const char *fn, uint32_t flags) { @@ -5149,10 +5410,10 @@ int32_t LoadBoard(const char *filename, uint32_t flags) for (i=0; i=0)-(wall[closest].nextwall>=0) <= 0) + if (dst=0)-(wall[closest].nextwall>=0) <= 0) dist = dst, closest = j; } } @@ -5345,6 +5610,7 @@ static int32_t adjustmark(int32_t *xplc, int32_t *yplc, int16_t danumwalls) *xplc = dax; *yplc = day; + return(0); } @@ -5426,41 +5692,44 @@ static void insertpoint(int16_t linehighlight, int32_t dax, int32_t day) { int16_t sucksect; int32_t i, j, k; + uint32_t templenrepquot; j = linehighlight; - sucksect = sectorofwall((int16_t)j); + sucksect = sectorofwall(j); + templenrepquot = divscale12(wallength(j), wall[j].xrepeat); + templenrepquot = max(1, templenrepquot); sector[sucksect].wallnum++; for (i=sucksect+1; i= 0) { k = wall[j].nextwall; - sucksect = sectorofwall((int16_t)k); + sucksect = sectorofwall(k); sector[sucksect].wallnum++; for (i=sucksect+1; i= 0) { NEXTWALL(i).nextwall = -1; NEXTWALL(i).nextsector = -1; } - j = endwall-startwall+1; - movewalls(startwall,-j); + movewalls(startwall, -j); for (i=0; i= startwall) wall[i].nextsector--; @@ -5547,8 +5816,8 @@ void fixspritesectors(void) int32_t i, j, dax, day, daz; for (i=numsectors-1; i>=0; i--) - if ((sector[i].wallnum <= 0) || (sector[i].wallptr >= numwalls)) - deletesector((int16_t)i); + if (sector[i].wallnum <= 0 || sector[i].wallptr >= numwalls) + deletesector(i); for (i=0; i= getceilzofslope(j,dax,day)) - if (sprite[i].z-daz <= getflorzofslope(j,dax,day)) - { - changespritesect((int16_t)i,(int16_t)j); - break; - } + if (inside(dax,day, j) == 1 + && sprite[i].z >= getceilzofslope(j,dax,day) + && sprite[i].z-daz <= getflorzofslope(j,dax,day)) + { + changespritesect(i, j); + break; + } } } } @@ -5579,22 +5848,39 @@ static int32_t movewalls(int32_t start, int32_t offs) if (offs < 0) //Delete { for (i=start; i 0) //Insert { for (i=numwalls+offs-1; i>=start+offs; i--) - Bmemcpy(&wall[i],&wall[i-offs],sizeof(walltype)); + Bmemcpy(&wall[i], &wall[i-offs], sizeof(walltype)); } + numwalls += offs; for (i=0; i= start) wall[i].nextwall += offs; if (wall[i].point2 >= start) wall[i].point2 += offs; } + return(0); } +int32_t wallength(int16_t i) +{ + int64_t dax = POINT2(i).x - wall[i].x; + int64_t day = POINT2(i).y - wall[i].y; +#if 1 //def POLYMOST + int64_t hypsq = dax*dax + day*day; + if (hypsq > (int64_t)INT_MAX) + return (int32_t)sqrt((double)hypsq); + else + return ksqrt((int32_t)hypsq); +#else + return ksqrt(dax*dax + day*day); +#endif +} + void fixrepeats(int16_t i) { int32_t dist = wallength(i); @@ -5603,6 +5889,12 @@ void fixrepeats(int16_t i) wall[i].xrepeat = clamp(mulscale10(dist,day), 1, 255); } +void fixxrepeat(int16_t i, uint32_t lenrepquot) // lenrepquot: divscale12(wallength,xrepeat) +{ + if (lenrepquot != 0) + wall[i].xrepeat = clamp(divscale12(wallength(i), lenrepquot), 1, 255); +} + int32_t overridepm16y = -1; @@ -5627,7 +5919,8 @@ void clearmidstatbar16(void) static void clearministatbar16(void) { int32_t i, col = whitecol - 21; - static const char *tempbuf = "Mapster32" VERSION; +// static const char *tempbuf = "Mapster32" " " VERSION; + char tempbuf[16]; begindrawing(); @@ -5642,6 +5935,7 @@ static void clearministatbar16(void) CLEARLINES2D(i, ydim-i, 0); + Bsprintf(tempbuf, "Mapster32 %s", ExtGetVer()); printext16(xdim2d-(Bstrlen(tempbuf)<<3)-3, ydim2d-STATUS2DSIZ2+10, editorcolors[4],-1, tempbuf, 0); printext16(xdim2d-(Bstrlen(tempbuf)<<3)-2, ydim2d-STATUS2DSIZ2+9, editorcolors[12],-1, tempbuf, 0); @@ -5775,10 +6069,9 @@ int32_t _getnumber256(const char *namestart, int32_t num, int32_t maxnumber, cha quitevent = 0; drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); -#ifdef SUPERBUILD ExtAnalyzeSprites(); -#endif drawmasks(); + #ifdef POLYMER if (rendmode == 4 && searchit == 2) { @@ -6313,9 +6606,11 @@ static int32_t menuselect(void) return(-1); } +static int32_t fillsectorxy[MAXWALLS][2]; + int32_t fillsector(int16_t sectnum, char fillcolor) { - int32_t x1, x2, y1, y2, sy, y, tempint; + int32_t x1, x2, y1, y2, sy, y; int32_t lborder, rborder, uborder, dborder, miny, maxy, dax; int16_t z, zz, startwall, endwall, fillcnt; @@ -6334,12 +6629,21 @@ int32_t fillsector(int16_t sectnum, char fillcolor) endwall = startwall + sector[sectnum].wallnum - 1; for (z=startwall; z<=endwall; z++) { - y1 = (((wall[z].y-pos.y)*zoom)>>14)+midydim16; - y2 = (((POINT2(z).y-pos.y)*zoom)>>14)+midydim16; - if (y1 < miny) miny = y1; - if (y2 < miny) miny = y2; - if (y1 > maxy) maxy = y1; - if (y2 > maxy) maxy = y2; + screencoords(&x1,&y1, wall[z].x-pos.x,wall[z].y-pos.y, zoom); + if (m32_sideview) + y1 += getscreenvdisp(getflorzofslope(sectnum,wall[z].x,wall[z].y)-pos.z, zoom); + + x1 += halfxdim16; + y1 += midydim16; + + if (m32_sideview) + { + fillsectorxy[z][0] = x1; + fillsectorxy[z][1] = y1; + } + + miny = min(miny, y1); + maxy = max(maxy, y1); } if (miny < uborder) miny = uborder; @@ -6348,37 +6652,66 @@ int32_t fillsector(int16_t sectnum, char fillcolor) //+((totalclock>>2)&3) for (sy=miny; sy<=maxy; sy+=3) // JBF 20040116: numframes%3 -> (totalclock>>2)&3 { - y = pos.y+(((sy-midydim16)<<14)/zoom); + y = pos.y + ((sy-midydim16)<<14)/zoom; fillist[0] = lborder; fillcnt = 1; for (z=startwall; z<=endwall; z++) { - x1 = wall[z].x; x2 = POINT2(z).x; - y1 = wall[z].y; y2 = POINT2(z).y; - if (y1 > y2) + if (m32_sideview) { - tempint = x1; x1 = x2; x2 = tempint; - tempint = y1; y1 = y2; y2 = tempint; + x1 = fillsectorxy[z][0]; + y1 = fillsectorxy[z][1]; + x2 = fillsectorxy[wall[z].point2][0]; + y2 = fillsectorxy[wall[z].point2][1]; + + if (y1 > y2) + { + swaplong(&x1, &x2); + swaplong(&y1, &y2); + } + + if (y1 <= sy && sy < y2) + { + if (fillcnt == sizeof(fillist)/sizeof(fillist[0])) + break; + + x1 += scale(sy-y1, x2-x1, y2-y1); + fillist[fillcnt++] = x1; + } } - if ((y1 <= y) && (y2 > y)) - //if (x1*(y-y2) + x2*(y1-y) <= 0) + else { - dax = x1+scale(y-y1,x2-x1,y2-y1); - dax = (((dax-pos.x)*zoom)>>14)+halfxdim16; - if (dax >= lborder) - fillist[fillcnt++] = dax; + x1 = wall[z].x; x2 = POINT2(z).x; + y1 = wall[z].y; y2 = POINT2(z).y; + + if (y1 > y2) + { + swaplong(&x1, &x2); + swaplong(&y1, &y2); + } + + if (y1 <= y && y < y2) + //if (x1*(y-y2) + x2*(y1-y) <= 0) + { + dax = x1 + scale(y-y1, x2-x1, y2-y1); + dax = halfxdim16 + (((dax-pos.x)*zoom)>>14); + if (dax >= lborder) + { + if (fillcnt == sizeof(fillist)/sizeof(fillist[0])) + break; + + fillist[fillcnt++] = dax; + } + } } } + if (fillcnt > 0) { for (z=1; z rborder) fillist[z+1] = rborder; + drawline16(fillist[z],sy, fillist[z+1],sy, 159 //editorcolors[fillcolor] -klabs(sintable[((totalclock<<3)&2047)]>>11)); } } } + return(0); } -int16_t whitelinescan(int16_t dalinehighlight) +static int16_t whitelinescan(int16_t dalinehighlight) { int32_t i, j, k; - int16_t sucksect, newnumwalls; + int16_t sucksect, tnewnumwalls; sucksect = sectorofwall(dalinehighlight); - Bmemcpy(§or[numsectors],§or[sucksect],sizeof(sectortype)); + if (numsectors >= MAXSECTORS) + return MAXWALLS+1; + + Bmemcpy(§or[numsectors], §or[sucksect], sizeof(sectortype)); sector[numsectors].wallptr = numwalls; sector[numsectors].wallnum = 0; i = dalinehighlight; - newnumwalls = numwalls; + tnewnumwalls = numwalls; do { - j = lastwall((int16_t)i); + if (tnewnumwalls >= MAXWALLS) + return MAXWALLS+1; + + j = lastwall(i); if (wall[j].nextwall >= 0) { j = wall[j].point2; @@ -6424,40 +6765,57 @@ int16_t whitelinescan(int16_t dalinehighlight) } } - Bmemcpy(&wall[newnumwalls],&wall[i],sizeof(walltype)); + Bmemcpy(&wall[tnewnumwalls], &wall[i], sizeof(walltype)); - wall[newnumwalls].nextwall = j; - wall[newnumwalls].nextsector = sectorofwall((int16_t)j); + wall[tnewnumwalls].nextwall = j; + wall[tnewnumwalls].nextsector = sectorofwall(j); - newnumwalls++; + tnewnumwalls++; sector[numsectors].wallnum++; i = j; } while (i != dalinehighlight); - for (i=numwalls; i MAXSECTORSV7 || numwalls > MAXWALLSV7 || numsprites > MAXSPRITESV7); Bsprintf(snotbuf,"x:%d y:%d ang:%d r%d",posxe,posye,ange,map_revision-1); i = 0; @@ -6587,24 +6946,44 @@ void printcoords16(int32_t posxe, int32_t posye, int16_t ange) printext16(8, ydim-STATUS2DSIZ+128, whitecol, -1, snotbuf,0); - m = (numsectors > MAXSECTORSV7 || numwalls > MAXWALLSV7 || numsprites > MAXSPRITESV7); + if (highlightcnt<=0 && highlightsectorcnt<=0) + { + Bsprintf(snotbuf,"%d/%d sect. %d/%d walls %d/%d spri.", + numsectors, v8?MAXSECTORSV8:MAXSECTORSV7, + numwalls, v8?MAXWALLSV8:MAXWALLSV7, + numsprites, v8?MAXSPRITESV8:MAXSPRITESV7); + } + else + { + if (highlightcnt>0) + { + m = 0; + for (i=0; i0) + Bsprintf(snotbuf, "%d sectors selected", highlightsectorcnt); + else + snotbuf[0] = 0; - Bsprintf(snotbuf,"%d/%d sect. %d/%d walls %d/%d spri.", - numsectors, m?MAXSECTORSV8:MAXSECTORSV7, - numwalls, m?MAXWALLSV8:MAXWALLSV7, - numsprites, m?MAXSPRITESV8:MAXSPRITESV7); + v8 = 1; + } + + m = xdim/8 - 264/8; + m = clamp(m, 1, (signed)sizeof(snotbuf)-1); i = 0; - while ((snotbuf[i] != 0) && (i < 46)) + while (snotbuf[i] && i < m) i++; - while (i < 46) + while (i < m) { snotbuf[i] = 32; i++; } - snotbuf[46] = 0; + snotbuf[m] = 0; - printext16(264, ydim-STATUS2DSIZ+128, m?editorcolors[10]:whitecol, -1, snotbuf,0); + printext16(264, ydim-STATUS2DSIZ+128, v8?editorcolors[10]:whitecol, -1, snotbuf,0); } void updatenumsprites(void) @@ -6613,7 +6992,7 @@ void updatenumsprites(void) numsprites = 0; for (i=0; i= 0) { m = insertsprite(destsector,sprite[j].statnum); - if (m>=0) + if (m<0) { - Bmemcpy(&sprite[m],&sprite[j],sizeof(spritetype)); - sprite[m].sectnum = destsector; //Don't let memcpy overwrite sector! + message("Some sprites not duplicated because limit was reached."); + break; } + + Bmemcpy(&sprite[m],&sprite[j],sizeof(spritetype)); + sprite[m].sectnum = destsector; //Don't let memcpy overwrite sector! + j = nextspritesect[j]; } } @@ -6985,8 +7369,6 @@ static void initcrc(void) } } -static char visited[MAXWALLS]; - static int32_t GetWallZPeg(int32_t nWall) { int32_t z=0, nSector, nNextSector; @@ -7040,8 +7422,8 @@ void AutoAlignWalls(int32_t nWall0, int32_t ply) if (ply == 0) { //clear visited bits - Bmemset(visited,0,sizeof(visited)); - visited[nWall0] = 1; + Bmemset(visited, 0, sizeof(visited)); + visited[nWall0>>3] |= (1<<(nWall0&7)); } z0 = GetWallZPeg(nWall0); @@ -7052,12 +7434,14 @@ void AutoAlignWalls(int32_t nWall0, int32_t ply) while (1) { //break if this wall would connect us in a loop - if (visited[nWall1]) break; + if (visited[nWall1>>3]&(1<<(nWall1&7))) + break; - visited[nWall1] = 1; + visited[nWall1>>3] |= (1<<(nWall1&7)); //break if reached back of left wall - if (wall[nWall1].nextwall == nWall0) break; + if (wall[nWall1].nextwall == nWall0) + break; if (wall[nWall1].picnum == nTile) { diff --git a/polymer-perf/eduke32/build/src/config.c b/polymer-perf/eduke32/build/src/config.c index cdaef54f3..e6cce4e0d 100644 --- a/polymer-perf/eduke32/build/src/config.c +++ b/polymer-perf/eduke32/build/src/config.c @@ -59,8 +59,8 @@ extern int16_t brightness; extern int32_t vsync; extern char game_executable[BMAX_PATH]; extern int32_t fullscreen; -extern char option[9]; -extern char keys[NUMBUILDKEYS]; +extern char default_buildkeys[NUMBUILDKEYS]; +static char *const keys = default_buildkeys; extern char remap[256]; extern int32_t remapinit; extern double msens; @@ -134,8 +134,8 @@ int32_t loadsetup(const char *fn) if (readconfig(fp, "xdim3d", val, VL) > 0) xdimgame = Batoi(val); if (readconfig(fp, "ydim3d", val, VL) > 0) ydimgame = Batoi(val); // if (readconfig(fp, "samplerate", val, VL) > 0) option[7] = (Batoi(val) & 0x0f) << 4; - if (readconfig(fp, "music", val, VL) > 0) { if (Batoi(val) != 0) option[2] = 1; else option[2] = 0; } - if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; } +// if (readconfig(fp, "music", val, VL) > 0) { if (Batoi(val) != 0) option[2] = 1; else option[2] = 0; } +// if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; } if (readconfig(fp, "bpp", val, VL) > 0) bppgame = Batoi(val); if (readconfig(fp, "vsync", val, VL) > 0) vsync = Batoi(val)?1:0; if (readconfig(fp, "editorgridextent", val, VL) > 0) editorgridextent = max(min(262144,Batoi(val)),32768); @@ -155,7 +155,7 @@ int32_t loadsetup(const char *fn) #ifdef RENDERTYPEWIN if (readconfig(fp, "maxrefreshfreq", val, VL) > 0) maxrefreshfreq = Batoi(val); #endif -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (readconfig(fp, "usemodels", val, VL) > 0) usemodels = Batoi(val)?1:0; if (readconfig(fp, "usehightile", val, VL) > 0) usehightile = Batoi(val)?1:0; @@ -187,10 +187,10 @@ int32_t loadsetup(const char *fn) if (readconfig(fp, "gameexecutable", val, VL) > 0) Bstrcpy(game_executable, val); - option[0] = 1; // vesa all the way... - option[1] = 1; // sound all the way... - option[4] = 0; // no multiplayer - option[5] = 0; +// option[0] = 1; // vesa all the way... +// option[1] = 1; // sound all the way... +// option[4] = 0; // no multiplayer +// option[5] = 0; #if 1 if (readconfig(fp, "keyforward", val, VL) > 0) keys[0] = Bstrtol(val, NULL, 16); @@ -345,7 +345,7 @@ int32_t writesetup(const char *fn) "; Startup grid size (0-8, 9 is automatic)\n" "grid = %d\n" "\n" -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL "; OpenGL mode options\n" "usemodels = %d\n" "usehightile = %d\n" @@ -393,11 +393,6 @@ int32_t writesetup(const char *fn) "music = %d\n" "\n" #endif - "; Enable mouse\n" - "; 0 - No\n" - "; 1 - Yes\n" - "mouse = %d\n" - "\n" "; Mouse sensitivity\n" "mousesensitivity = %g\n" "\n" @@ -511,7 +506,7 @@ int32_t writesetup(const char *fn) glrendmode, #endif editorgridextent, min(max(0, default_grid), 9), -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL usemodels, usehightile, glusetexcache, gltexfiltermode, glanisotropy,r_downsize,glusetexcompr, #endif @@ -525,7 +520,7 @@ int32_t writesetup(const char *fn) #if 0 option[7]>>4, option[2], #endif - option[3], msens, unrealedlook, pk_uedaccel, quickmapcycling, + msens, unrealedlook, pk_uedaccel, quickmapcycling, sideview_reversehrot, revertCTRL,scrollamount,pk_turnaccel,pk_turndecel,autosave,autocorruptcheck, showheightindicators,showambiencesounds,graphicsmode, diff --git a/polymer-perf/eduke32/build/src/defs.c b/polymer-perf/eduke32/build/src/defs.c index 002a3a23a..daed7423f 100644 --- a/polymer-perf/eduke32/build/src/defs.c +++ b/polymer-perf/eduke32/build/src/defs.c @@ -58,6 +58,7 @@ enum scripttoken_t T_YADD, T_ZADD, T_ANGADD, + T_FOV, T_FLIPPED, T_HIDE, T_NOBOB, @@ -105,7 +106,7 @@ static int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens) static int32_t lastmodelid = -1, lastvoxid = -1, modelskin = -1, lastmodelskin = -1, seenframe = 0; extern int32_t nextvoxid; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL extern float alphahackarray[MAXTILES]; #endif @@ -305,7 +306,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getsymbol(script,&tile)) break; if (scriptfile_getdouble(script,&alpha)) break; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if ((uint32_t)tile < MAXTILES) alphahackarray[tile] = alpha; #endif } @@ -325,7 +326,7 @@ static int32_t defsparser(scriptfile *script) tilenume2 = tilenume1; tilenume1 = i; } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if ((tilenume1 >= 0 && tilenume1 < MAXTILES) && (tilenume2 >= 0 && tilenume2 < MAXTILES)) { for (i=tilenume1; i<=tilenume2; i++) @@ -467,7 +468,7 @@ static int32_t defsparser(scriptfile *script) char *texturetokptr = script->ltextptr, *textureend, *fn = NULL, *tfn = NULL, *ftd = NULL; int32_t tile=-1, token, i; int32_t alphacut = 255; - int32_t xoffset = 0, yoffset = 0; + int32_t xoffset = 0, yoffset = 0, goodtogo=0; static const tokenlist tilefromtexturetokens[] = { @@ -526,6 +527,7 @@ static int32_t defsparser(scriptfile *script) } else Bfree(tfn); pathsearchmode = i; + goodtogo = 1; } if ((unsigned)tile >= (unsigned)MAXTILES) @@ -535,6 +537,7 @@ static int32_t defsparser(scriptfile *script) break; } + if (goodtogo) { int32_t xsiz, ysiz, j; int32_t *picptr = NULL; @@ -699,7 +702,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getdouble(script,&scale)) break; if (scriptfile_getnumber(script,&shadeoffs)) break; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL lastmodelid = md_loadmodel(modelfn); if (lastmodelid < 0) { @@ -715,7 +718,7 @@ static int32_t defsparser(scriptfile *script) case T_DEFINEMODELFRAME: { char *framename; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL char happy=1; #endif int32_t ftilenume, ltilenume, tilex; @@ -736,7 +739,7 @@ static int32_t defsparser(scriptfile *script) initprintf("Warning: Ignoring frame definition.\n"); break; } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) { switch (md_defineframe(lastmodelid, framename, tilex, max(0,modelskin), 0.0f,0)) @@ -777,7 +780,7 @@ static int32_t defsparser(scriptfile *script) initprintf("Warning: Ignoring animation definition.\n"); break; } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL switch (md_defineanimation(lastmodelid, startframe, endframe, (int32_t)(dfps*(65536.0*.001)), flags)) { case 0: @@ -823,7 +826,7 @@ static int32_t defsparser(scriptfile *script) if (seenframe) { modelskin = ++lastmodelskin; } seenframe = 0; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), 0, 0.0f, 1.0f, 1.0f)) { case 0: @@ -863,7 +866,6 @@ static int32_t defsparser(scriptfile *script) break; } -#ifdef SUPERBUILD if (qloadkvx(nextvoxid, fn)) { initprintf("Failure loading voxel file \"%s\"\n",fn); @@ -871,7 +873,6 @@ static int32_t defsparser(scriptfile *script) } lastvoxid = nextvoxid++; -#endif } break; case T_DEFINEVOXELTILES: @@ -901,12 +902,9 @@ static int32_t defsparser(scriptfile *script) initprintf("Warning: Ignoring voxel tiles definition.\n"); break; } -#ifdef SUPERBUILD + for (tilex = ftilenume; tilex <= ltilenume; tilex++) - { tiletovox[tilex] = lastvoxid; - } -#endif } break; @@ -938,7 +936,7 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getstring(script,&modelfn)) break; if (scriptfile_getbraces(script,&modelend)) break; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL lastmodelid = md_loadmodel(modelfn); if (lastmodelid < 0) { @@ -1016,7 +1014,7 @@ static int32_t defsparser(scriptfile *script) initprintf("Warning: Ignoring frame definition.\n"); break; } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) { switch (md_defineframe(lastmodelid, framename, tilex, max(0,modelskin), smoothduration,pal)) @@ -1081,7 +1079,7 @@ static int32_t defsparser(scriptfile *script) initprintf("Warning: Ignoring animation definition.\n"); break; } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL switch (md_defineanimation(lastmodelid, startframe, endframe, (int32_t)(dfps*(65536.0*.001)), flags)) { case 0: @@ -1170,7 +1168,7 @@ static int32_t defsparser(scriptfile *script) break; } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL switch (md_defineskin(lastmodelid, skinfn, palnum, max(0,modelskin), surfnum, param, specpower, specfactor)) { case 0: @@ -1197,7 +1195,7 @@ static int32_t defsparser(scriptfile *script) { char *hudtokptr = script->ltextptr; char happy=1, *frameend; - int32_t ftilenume = -1, ltilenume = -1, tilex = 0, flags = 0; + int32_t ftilenume = -1, ltilenume = -1, tilex = 0, flags = 0, fov = -1; double xadd = 0.0, yadd = 0.0, zadd = 0.0, angadd = 0.0; static const tokenlist modelhudtokens[] = @@ -1209,6 +1207,7 @@ static int32_t defsparser(scriptfile *script) { "yadd", T_YADD }, { "zadd", T_ZADD }, { "angadd", T_ANGADD }, + { "fov", T_FOV }, { "hide", T_HIDE }, { "nobob", T_NOBOB }, { "flipped",T_FLIPPED}, @@ -1234,6 +1233,8 @@ static int32_t defsparser(scriptfile *script) scriptfile_getdouble(script,&zadd); break; case T_ANGADD: scriptfile_getdouble(script,&angadd); break; + case T_FOV: + scriptfile_getsymbol(script,&fov); break; case T_HIDE: flags |= 1; break; case T_NOBOB: @@ -1262,10 +1263,10 @@ static int32_t defsparser(scriptfile *script) initprintf("Warning: Ignoring frame definition.\n"); break; } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) { - switch (md_definehud(lastmodelid, tilex, xadd, yadd, zadd, angadd, flags)) + switch (md_definehud(lastmodelid, tilex, xadd, yadd, zadd, angadd, flags, fov)) { case 0: break; @@ -1289,7 +1290,7 @@ static int32_t defsparser(scriptfile *script) } } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL md_setmisc(lastmodelid,(float)scale,shadeoffs,(float)mzadd,flags); #endif @@ -1314,10 +1315,8 @@ static int32_t defsparser(scriptfile *script) if (scriptfile_getstring(script,&fn)) break; //voxel filename if (nextvoxid == MAXVOXELS) { initprintf("Maximum number of voxels already defined.\n"); break; } -#ifdef SUPERBUILD if (qloadkvx(nextvoxid, fn)) { initprintf("Failure loading voxel file \"%s\"\n",fn); break; } lastvoxid = nextvoxid++; -#endif if (scriptfile_getbraces(script,&modelend)) break; while (script->textptr < modelend) @@ -1327,10 +1326,8 @@ static int32_t defsparser(scriptfile *script) //case T_ERROR: initprintf("Error on line %s:%d in voxel tokens\n", script->filename,linenum); break; case T_TILE: scriptfile_getsymbol(script,&tilex); -#ifdef SUPERBUILD if ((uint32_t)tilex < MAXTILES) tiletovox[tilex] = lastvoxid; else initprintf("Invalid tile number on line %s:%d\n",script->filename, scriptfile_getlinum(script,voxeltokptr)); -#endif break; case T_TILE0: scriptfile_getsymbol(script,&tile0); break; //1st tile # @@ -1343,17 +1340,13 @@ static int32_t defsparser(scriptfile *script) } if ((tile1 < 0) || (tile0 >= MAXTILES)) { initprintf("Invalid tile range on line %s:%d\n",script->filename, scriptfile_getlinum(script,voxeltokptr)); break; } -#ifdef SUPERBUILD for (tilex=tile0; tilex<=tile1; tilex++) tiletovox[tilex] = lastvoxid; -#endif break; //last tile number (inclusive) case T_SCALE: { double scale=1.0; scriptfile_getdouble(script,&scale); -#ifdef SUPERBUILD voxscale[lastvoxid] = (int32_t)(65536*scale); -#endif break; } } @@ -1823,7 +1816,7 @@ static int32_t defsparser(scriptfile *script) break; } } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL for (; r0 <= r1; r0++) md_undefinetile(r0); #endif } @@ -1832,7 +1825,7 @@ static int32_t defsparser(scriptfile *script) case T_UNDEFMODELOF: { int32_t r0; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL int32_t mid; #endif @@ -1843,7 +1836,7 @@ static int32_t defsparser(scriptfile *script) break; } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL mid = md_tilehasmodel(r0,0); if (mid < 0) break; diff --git a/polymer-perf/eduke32/build/src/engine.c b/polymer-perf/eduke32/build/src/engine.c index 27bc5e768..d189955b9 100644 --- a/polymer-perf/eduke32/build/src/engine.c +++ b/polymer-perf/eduke32/build/src/engine.c @@ -6,8 +6,6 @@ // by Jonathon Fowler (jonof@edgenetwk.com) -//#define POLYMOST -//#define SUPERBUILD #define ENGINE #include "compat.h" @@ -22,7 +20,7 @@ #include "baselayer.h" #include "scriptfile.h" -#ifdef POLYMOST +#ifdef USE_OPENGL # ifdef USE_OPENGL # include "glbuild.h" # include "mdsprite.h" @@ -71,7 +69,6 @@ static void drawpixel_safe(void *s, char a) #endif } -#ifdef SUPERBUILD void loadvoxel(int32_t voxindex) { voxindex=0; } int32_t tiletovox[MAXTILES]; int32_t usevoxels = 1; @@ -91,7 +88,6 @@ int32_t voxscale[MAXVOXELS]; static int32_t ggxinc[MAXXSIZ+1], ggyinc[MAXXSIZ+1]; static int32_t lowrecip[1024], nytooclose, nytoofar; static uint32_t distrecip[65536]; -#endif static intptr_t *lookups = NULL; static char lookupsalloctype = 255; @@ -173,6 +169,36 @@ static int16_t maphacklightcnt=0; static int16_t maphacklight[PR_MAXLIGHTS]; #endif +// forward refs +inline int32_t getscreenvdisp(int32_t bz, int32_t zoome); +void screencoords(int32_t *xres, int32_t *yres, int32_t x, int32_t y, int32_t zoome); + + +////////// YAX ////////// +#define YAX_BUNCHNUM(Sect, Cf) (*(int16_t *)(§or[Sect].ceilingxpanning + 6*Cf)) + +int16_t yax_getbunch(int16_t i, int16_t cf) +{ + if (((*(§or[i].ceilingstat + cf))&YAX_BIT)==0) + return -1; + + return YAX_BUNCHNUM(i, cf); +} + +void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum) +{ + if (i<0) + { + *(§or[i].ceilingstat + cf) &= ~YAX_BIT; + YAX_BUNCHNUM(i, cf) = 0; + return; + } + + *(§or[i].ceilingstat + cf) |= YAX_BIT; + YAX_BUNCHNUM(i, cf) = bunchnum; +} + + ////////// editor side view ////////// int32_t m32_sideview = 0; int32_t m32_sideelev = 256; // elevation in BUILD degrees, 0..512 @@ -295,7 +321,7 @@ int32_t clipmapinfo_load(const char *filename) int32_t i,k,w, px,py,pz; int16_t ang,cs; - char fn[BMAX_PATH], loadedwhich[32]= {0}, *lwcp=loadedwhich; + char fn[BMAX_PATH], loadedwhich[32]={0}, *lwcp=loadedwhich; int32_t slen, fi, fisec[10], fispr[10]; int32_t ournumsectors=0, ournumwalls=0, ournumsprites=0, numsprites; @@ -755,7 +781,7 @@ int32_t checksectorpointer(int16_t i, int16_t sectnum) for (k=startwall; k<=endwall; k++) { if (wall[k].x == x2 && wall[k].y == y2) - if ((wall[wall[k].point2]).x == x1 && (wall[wall[k].point2]).y == y1) + if (wall[wall[k].point2].x == x1 && wall[wall[k].point2].y == y1) if (j != sectnum) { // Don't create link if the other side is connected to another wall. @@ -1137,7 +1163,7 @@ static int32_t colscan[27]; static int16_t clipnum, hitwalls[4]; const int32_t hitscangoalx = (1<<29)-1, hitscangoaly = (1<<29)-1; -#ifdef POLYMOST +#ifdef USE_OPENGL int32_t hitallsprites = 0; #endif @@ -1191,7 +1217,7 @@ static int32_t setviewcnt = 0; // interface layers use this now static int32_t bakframeplace[4], bakxsiz[4], bakysiz[4]; static int32_t bakwindowx1[4], bakwindowy1[4]; static int32_t bakwindowx2[4], bakwindowy2[4]; -#ifdef POLYMOST +#ifdef USE_OPENGL static int32_t bakrendmode,baktile; #endif @@ -3425,7 +3451,6 @@ static void drawalls(int32_t bunch) // // drawvox // -#ifdef SUPERBUILD static void drawvox(int32_t dasprx, int32_t daspry, int32_t dasprz, int32_t dasprang, int32_t daxscale, int32_t dayscale, char daindex, int8_t dashade, char dapal, int32_t *daumost, int32_t *dadmost) @@ -3674,7 +3699,6 @@ static void drawvox(int32_t dasprx, int32_t daspry, int32_t dasprz, int32_t dasp enddrawing(); //}}} } -#endif // // drawsprite (internal) @@ -3694,7 +3718,7 @@ static void drawsprite(int32_t snum) char swapped, daclip; //============================================================================= //POLYMOST BEGINS -#ifdef POLYMOST +#ifdef USE_OPENGL if (rendmode == 3) { polymost_drawsprite(snum); @@ -3729,10 +3753,9 @@ static void drawsprite(int32_t snum) if (tilenum < 0 || tilenum >= MAXSPRITES) return; -#ifdef SUPERBUILD if ((cstat&48)==48) vtilenum = tilenum; // if the game wants voxels, it gets voxels else if ((cstat&48)!=48 && (usevoxels) && (tiletovox[tilenum] != -1) -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL && (!(spriteext[tspr->owner].flags&SPREXT_NOTMD)) #endif ) @@ -3740,7 +3763,6 @@ static void drawsprite(int32_t snum) vtilenum = tiletovox[tilenum]; cstat |= 48; } -#endif if ((cstat&48) != 48) { @@ -4491,7 +4513,6 @@ static void drawsprite(int32_t snum) //Draw it! ceilspritescan(lx,rx-1); } -#ifdef SUPERBUILD else if ((cstat&48) == 48) { int32_t nxrepeat, nyrepeat; @@ -4617,12 +4638,11 @@ static void drawsprite(int32_t snum) } i = (int32_t)tspr->ang+1536; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL i += spriteext[tspr->owner].angoff; #endif drawvox(tspr->x,tspr->y,tspr->z,i,(int32_t)tspr->xrepeat,(int32_t)tspr->yrepeat,vtilenum,tspr->shade,tspr->pal,lwall,swall); } -#endif if (automapping == 1) show2dsprite[spritenum>>3] |= pow2char[spritenum&7]; } @@ -4637,7 +4657,7 @@ static void drawmaskwall(int16_t damaskwallcnt) walltype *wal; //============================================================================= //POLYMOST BEGINS -#ifdef POLYMOST +#ifdef USE_OPENGL if (rendmode == 3) { polymost_drawmaskwall(damaskwallcnt); return; } # ifdef POLYMER if (rendmode == 4) @@ -4754,7 +4774,7 @@ static void fillpolygon(int32_t npoints) int16_t *ptr, *ptr2; intptr_t p; -#if defined POLYMOST && defined USE_OPENGL +#ifdef USE_OPENGL if (rendmode >= 3 && qsetmode == 200) { polymost_fillpolygon(npoints); return; } #endif @@ -5147,11 +5167,8 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t UNREFERENCED_PARAMETER(uniqid); //============================================================================= //POLYMOST BEGINS -#ifdef POLYMOST +#ifdef USE_OPENGL if (rendmode >= 3 && qsetmode == 200) { polymost_dorotatesprite(sx,sy,z,a,picnum,dashade,dapalnum,dastat,cx1,cy1,cx2,cy2,uniqid); return; } -# ifdef POLYMER - if (rendmode == 4 && qsetmode == 200) { polymer_rotatesprite(sx,sy,z,a,picnum,dashade,dapalnum,dastat,cx1,cy1,cx2,cy2); return; } -#endif #endif //============================================================================= //POLYMOST ENDS @@ -5669,11 +5686,9 @@ static void dosetaspect(void) if (j != 0) j = mulscale16((int32_t)radarang[k+1]-(int32_t)radarang[k],j); radarang2[i] = (int16_t)(((int32_t)radarang[k]+j)>>6); } -#ifdef SUPERBUILD for (i=1; i<65536; i++) distrecip[i] = divscale20(xdimen,i); nytooclose = xdimen*2100; nytoofar = 65536*16384-1048576; -#endif } } @@ -6056,6 +6071,7 @@ static inline void keepaway(int32_t *x, int32_t *y, int32_t w) y1 = clipit[w].y1; dy = clipit[w].y2-y1; ox = ksgn(-dy); oy = ksgn(dx); first = (klabs(dx) <= klabs(dy)); + while (1) { if (dx*(*y-y1) > (*x-x1)*dy) return; @@ -6152,13 +6168,13 @@ static void sighandler(int32_t sig, const siginfo_t *info, void *ctx) // static int32_t preinitcalled = 0; -#define DYNALLOC_ARRAYS +// #define DYNALLOC_ARRAYS #ifndef DYNALLOC_ARRAYS static spriteext_t spriteext_s[MAXSPRITES+MAXUNIQHUDID]; static spritesmooth_t spritesmooth_s[MAXSPRITES+MAXUNIQHUDID]; -static sectortype sector_s[MAXSECTORS]; -static walltype wall_s[MAXWALLS]; +static sectortype sector_s[MAXSECTORS + M32_FIXME_SECTORS]; +static walltype wall_s[MAXWALLS + M32_FIXME_WALLS]; static spritetype sprite_s[MAXSPRITES]; static spritetype tsprite_s[MAXSPRITESONSCREEN]; #else @@ -6186,7 +6202,7 @@ int32_t preinitengine(void) dynarray[] = { { (void **) §or, sizeof(sectortype) *MAXSECTORS }, - { (void **) &wall, sizeof(walltype) *MAXWALLS }, // +1024: editor quirks. FIXME! + { (void **) &wall, sizeof(walltype) *MAXWALLS }, // +512: editor quirks. FIXME! { (void **) &sprite, sizeof(spritetype) *MAXSPRITES }, { (void **) &tsprite, sizeof(spritetype) *MAXSPRITESONSCREEN }, { (void **) &spriteext, sizeof(spriteext_t) *(MAXSPRITES+MAXUNIQHUDID) }, @@ -6197,8 +6213,9 @@ int32_t preinitengine(void) if (editstatus) { - dynarray[1].size += 1024*sizeof(walltype); - Bprintf("FIXME: Allocating additional space beyong wall[] for editor bugs.\n"); + dynarray[0].size += M32_FIXME_SECTORS*sizeof(sectortype); // join sectors needs a temp. sector + dynarray[1].size += M32_FIXME_WALLS*sizeof(walltype); + Bprintf("FIXME: Allocating additional space beyond wall[] for editor bugs.\n"); } for (i=0; i<(signed)(sizeof(dynarray)/sizeof(dynarray[0])); i++) @@ -6277,7 +6294,6 @@ int32_t initengine(void) parallaxtype = 2; parallaxyoffs = 0L; parallaxyscale = 65536; showinvisibility = 0; -#ifdef SUPERBUILD for (i=1; i<1024; i++) lowrecip[i] = ((1<<24)-1)/i; for (i=0; i>2,65536L); -#endif paletteloaded = 0; @@ -6314,7 +6329,7 @@ int32_t initengine(void) captureformat = 0; loadpalette(); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (!hicfirstinit) hicinit(); if (!mdinited) mdinit(); #endif @@ -6332,7 +6347,7 @@ void uninitengine(void) //OSD_Printf("cacheresets = %d, cacheinvalidates = %d\n", cacheresets, cacheinvalidates); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL polymost_glreset(); hicinit(); freeallmodels(); @@ -6469,7 +6484,7 @@ void drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, umost[0] = shortptr1[0]-windowy1; dmost[0] = shortptr2[0]-windowy1; -#ifdef POLYMOST +#ifdef USE_OPENGL # ifdef POLYMER if (rendmode == 4) { @@ -6844,7 +6859,7 @@ void drawmasks(void) }*/ { -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL curpolygonoffset = 0; cullcheckcnt = 0; #endif @@ -6903,7 +6918,7 @@ void drawmasks(void) if (tspriteptr[spritesortcnt] != NULL) drawsprite(spritesortcnt); } -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL if (totalclock < lastcullcheck - CULL_DELAY) lastcullcheck = totalclock; if (totalclock >= lastcullcheck + CULL_DELAY) @@ -7230,7 +7245,9 @@ int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy, int16_t *daang, int16_t *dacursectnum) { int16_t fil, i, numsprites, dq[MAXSPRITES], dnum = 0; +#ifdef POLYMER char myflags = flags&(~3); +#endif flags &= 3; @@ -7396,7 +7413,7 @@ int32_t loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy, { Bmemset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL Bmemset(spritesmooth, 0, sizeof(spritesmooth_t) *(MAXSPRITES+MAXUNIQHUDID)); // polymost_cachesync(); @@ -7864,7 +7881,7 @@ int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *d kclose(fil); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL memset(spriteext, 0, sizeof(spriteext_t) * MAXSPRITES); memset(spritesmooth, 0, sizeof(spritesmooth_t) *(MAXSPRITES+MAXUNIQHUDID)); #endif @@ -7891,9 +7908,9 @@ void delete_maphack_lights() {} // // loadmaphack // -#if defined(POLYMOST) && defined(USE_OPENGL) int32_t loadmaphack(const char *filename) { +#ifdef USE_OPENGL enum { T_EOF = -2, @@ -8175,10 +8192,11 @@ int32_t loadmaphack(const char *filename) scriptfile_close(script); return 0; -} #else -int32_t loadmaphack(char *filename) { UNREFERENCED_PARAMETER(filename); return -1; } + UNREFERENCED_PARAMETER(filename); + return -1; #endif +} // @@ -8365,7 +8383,7 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da { int32_t i, j; -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL extern char nogl; if (nogl) dabpp = 8; @@ -8395,7 +8413,7 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da // Workaround possible bugs in the GL driver makeasmwriteable(); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (dabpp > 8) rendmode = glrendmode; // GL renderer else if (dabpp == 8 && j > 8) rendmode = 0; // going from GL to software activates softpolymost #endif @@ -8434,7 +8452,7 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da if (searchx < 0) { searchx = halfxdimen; searchy = (ydimen>>1); } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (rendmode >= 3) { polymost_glreset(); @@ -8784,7 +8802,6 @@ void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, in // // qloadkvx // -#ifdef SUPERBUILD int32_t qloadkvx(int32_t voxindex, const char *filename) { int32_t i, fil, dasiz, lengcnt, lengtot; @@ -8809,7 +8826,7 @@ int32_t qloadkvx(int32_t voxindex, const char *filename) } kclose(fil); -#if defined POLYMOST && defined USE_OPENGL +#ifdef USE_OPENGL if (voxmodels[voxindex]) { voxfree(voxmodels[voxindex]); @@ -8819,7 +8836,6 @@ int32_t qloadkvx(int32_t voxindex, const char *filename) #endif return 0; } -#endif // @@ -8928,6 +8944,27 @@ int32_t krecip(int32_t num) return(krecipasm(num)); } +int32_t spriteheight(int16_t i, int32_t *basez) +{ + int32_t hei, flooraligned=((sprite[i].cstat&48)==32); + + if (flooraligned) + { + if (basez) + *basez = sprite[i].z; + return 0; + } + + hei = (tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2; + if (basez) + { + *basez = sprite[i].z; + if (sprite[i].cstat&128) + *basez -= (hei>>1); + } + return hei; +} + // // setsprite // @@ -9142,7 +9179,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, const sectortype *sec, hitdat } } } - else if ((how*vz > 0) && (how *sv->z <= how*z)) + else if ((how*vz > 0) && (how*sv->z <= how*z)) { z1 = z; i = z1-sv->z; if ((klabs(i)>>1) < vz*how) @@ -9347,7 +9384,7 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32 { spr = &sprite[z]; cstat = spr->cstat; -#ifdef POLYMOST +#ifdef USE_OPENGL if (!hitallsprites) #endif if ((cstat&dasprclipmask) == 0) continue; @@ -9502,7 +9539,8 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32 // // neartag // -int32_t neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, int16_t *neartagsector, int16_t *neartagwall, int16_t *neartagsprite, int32_t *neartaghitdist, int32_t neartagrange, char tagsearch) +int32_t neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, int16_t *neartagsector, int16_t *neartagwall, + int16_t *neartagsprite, int32_t *neartaghitdist, int32_t neartagrange, uint8_t tagsearch) { walltype *wal, *wal2; spritetype *spr; @@ -9514,8 +9552,7 @@ int32_t neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ang *neartagsector = -1; *neartagwall = -1; *neartagsprite = -1; *neartaghitdist = 0; - if (sectnum < 0) return(0); - if ((tagsearch < 1) || (tagsearch > 3)) return(0); + if (sectnum < 0 || (tagsearch & 3) == 0) return(0); vx = mulscale14(sintable[(ange+2560)&2047],neartagrange); xe = xs+vx; vy = mulscale14(sintable[(ange+2048)&2047],neartagrange); ye = ys+vy; @@ -9567,6 +9604,10 @@ int32_t neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ang } } + tempshortcnt++; + + if (tagsearch & 4) continue; // skip sprite search + for (z=headspritesect[dasector]; z>=0; z=nextspritesect[z]) { spr = &sprite[z]; @@ -9614,8 +9655,6 @@ int32_t neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ang } } } - - tempshortcnt++; } while (tempshortcnt < tempshortnum); return(0); @@ -9628,6 +9667,7 @@ int32_t neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ang void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day) { int16_t cnt, tempshort; + int32_t thelastwall; wall[pointhighlight].x = dax; wall[pointhighlight].y = day; @@ -9652,9 +9692,10 @@ void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day) tempshort = pointhighlight; //search points CW if not searched all the way around do { - if (wall[lastwall(tempshort)].nextwall >= 0) + thelastwall = lastwall(tempshort); + if (wall[thelastwall].nextwall >= 0) { - tempshort = wall[lastwall(tempshort)].nextwall; + tempshort = wall[thelastwall].nextwall; wall[tempshort].x = dax; wall[tempshort].y = day; wall[tempshort].cstat |= (1<<14); @@ -9845,7 +9886,7 @@ static void addclipline(int32_t dax1, int32_t day1, int32_t dax2, int32_t day2, // // clipmove // -int32_t clipmove(vec3_t *vect, int16_t *sectnum, +int32_t clipmove(vec3_t *pos, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype) { @@ -9871,16 +9912,16 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, oxvect = xvect; oyvect = yvect; - goalx = (vect->x) + (xvect>>14); - goaly = (vect->y) + (yvect>>14); + goalx = pos->x + (xvect>>14); + goaly = pos->y + (yvect>>14); clipnum = 0; - cx = (((vect->x)+goalx)>>1); - cy = (((vect->y)+goaly)>>1); + cx = (pos->x+goalx)>>1; + cy = (pos->y+goaly)>>1; //Extra walldist for sprites on sector lines - gx = goalx-(vect->x); gy = goaly-(vect->y); + gx = goalx-(pos->x); gy = goaly-(pos->y); rad = nsqrtasm(gx*gx + gy*gy) + MAXCLIPDIST+walldist + 8; xmin = cx-rad; ymin = cy-rad; xmax = cx+rad; ymax = cy+rad; @@ -9925,7 +9966,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, continue; } - clipsprite_initindex(curidx, curspr, &clipsectcnt, vect); + clipsprite_initindex(curidx, curspr, &clipsectcnt, pos); } @@ -9946,7 +9987,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, x1 = wal->x; y1 = wal->y; x2 = wal2->x; y2 = wal2->y; dx = x2-x1; dy = y2-y1; - if (dx*((vect->y)-y1) < ((vect->x)-x1)*dy) continue; //If wall's not facing you + if (dx*((pos->y)-y1) < ((pos->x)-x1)*dy) continue; //If wall's not facing you if (dx > 0) dax = dx*(ymin-y1); else dax = dx*(ymax-y1); if (dy > 0) day = dy*(xmax-x1); else day = dy*(xmin-x1); @@ -9959,25 +10000,25 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, { int32_t basez; - if (rintersect(vect->x,vect->y,0, gx,gy,0, x1,y1, x2,y2, &dax,&day,&daz) == 0) - dax = vect->x, day = vect->y; - daz = getflorzofslope((int16_t)dasect,dax,day); - daz2 = getflorzofslope(wal->nextsector,dax,day); - basez = getflorzofslope(sectq[clipinfo[curidx].qend],dax,day); + if (rintersect(pos->x,pos->y,0, gx,gy,0, x1,y1, x2,y2, &dax,&day,&daz) == 0) + dax = pos->x, day = pos->y; + daz = getflorzofslope(dasect, dax,day); + daz2 = getflorzofslope(wal->nextsector, dax,day); + basez = getflorzofslope(sectq[clipinfo[curidx].qend], dax,day); sec2 = §or[wal->nextsector]; if ((sec2->floorstat&1) == 0) // if (dasect==sectq[clipinfo[curidx].qend] || daz2 < daz-(1<<8)) - if (daz2-(flordist-1) <= vect->z && vect->z <= basez+(flordist-1)) + if (daz2-(flordist-1) <= pos->z && pos->z <= basez+(flordist-1)) clipyou = 1; if (clipyou == 0) { - daz = getceilzofslope((int16_t)dasect,dax,day); - daz2 = getceilzofslope(wal->nextsector,dax,day); - basez = getceilzofslope(sectq[clipinfo[curidx].qend],dax,day); + daz = getceilzofslope(dasect, dax,day); + daz2 = getceilzofslope(wal->nextsector, dax,day); + basez = getceilzofslope(sectq[clipinfo[curidx].qend], dax,day); if ((sec2->ceilingstat&1) == 0) // if (dasect==sectq[clipinfo[curidx].qend] || daz2 > daz+(1<<8)) - if (basez-(ceildist-1) <= vect->z && vect->z <= daz2+(ceildist-1)) + if (basez-(ceildist-1) <= pos->z && pos->z <= daz2+(ceildist-1)) clipyou = 1; } } @@ -9985,22 +10026,22 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, else if ((wal->nextsector < 0) || (wal->cstat&dawalclipmask)) clipyou = 1; else if (editstatus == 0) { - if (rintersect(vect->x,vect->y,0,gx,gy,0,x1,y1,x2,y2,&dax,&day,&daz) == 0) - dax = vect->x, day = vect->y; - daz = getflorzofslope((int16_t)dasect,dax,day); - daz2 = getflorzofslope(wal->nextsector,dax,day); + if (rintersect(pos->x,pos->y,0,gx,gy,0,x1,y1,x2,y2,&dax,&day,&daz) == 0) + dax = pos->x, day = pos->y; + daz = getflorzofslope(dasect, dax,day); + daz2 = getflorzofslope(wal->nextsector, dax,day); sec2 = §or[wal->nextsector]; if (daz2 < daz-(1<<8)) if ((sec2->floorstat&1) == 0) - if ((vect->z) >= daz2-(flordist-1)) clipyou = 1; + if ((pos->z) >= daz2-(flordist-1)) clipyou = 1; if (clipyou == 0) { - daz = getceilzofslope((int16_t)dasect,dax,day); - daz2 = getceilzofslope(wal->nextsector,dax,day); + daz = getceilzofslope(dasect, dax,day); + daz2 = getceilzofslope(wal->nextsector, dax,day); if (daz2 > daz+(1<<8)) if ((sec2->ceilingstat&1) == 0) - if ((vect->z) <= daz2+(ceildist-1)) clipyou = 1; + if ((pos->z) <= daz2+(ceildist-1)) clipyou = 1; } } @@ -10014,15 +10055,15 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, //Add 2 boxes at endpoints bsz = walldist; if (gx < 0) bsz = -bsz; - addclipline(x1-bsz,y1-bsz,x1-bsz,y1+bsz,objtype); - addclipline(x2-bsz,y2-bsz,x2-bsz,y2+bsz,objtype); + addclipline(x1-bsz,y1-bsz, x1-bsz,y1+bsz, objtype); + addclipline(x2-bsz,y2-bsz, x2-bsz,y2+bsz, objtype); bsz = walldist; if (gy < 0) bsz = -bsz; - addclipline(x1+bsz,y1-bsz,x1-bsz,y1-bsz,objtype); - addclipline(x2+bsz,y2-bsz,x2-bsz,y2-bsz,objtype); + addclipline(x1+bsz,y1-bsz, x1-bsz,y1-bsz, objtype); + addclipline(x2+bsz,y2-bsz, x2-bsz,y2-bsz, objtype); dax = walldist; if (dy > 0) dax = -dax; day = walldist; if (dx < 0) day = -day; - addclipline(x1+dax,y1+day,x2+dax,y2+day,objtype); + addclipline(x1+dax,y1+day, x2+dax,y2+day, objtype); } else if (wal->nextsector>=0) { @@ -10054,7 +10095,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z; if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); - if (((vect->z) < daz+ceildist) && ((vect->z) > daz-k-flordist)) + if (((pos->z) < daz+ceildist) && ((pos->z) > daz-k-flordist)) { bsz = (spr->clipdist<<2)+walldist; if (gx < 0) bsz = -bsz; addclipline(x1-bsz,y1-bsz,x1-bsz,y1+bsz,(int16_t)j+49152); @@ -10069,7 +10110,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); daz2 = daz-k; daz += ceildist; daz2 -= flordist; - if (((vect->z) < daz) && ((vect->z) > daz2)) + if (((pos->z) < daz) && ((pos->z) > daz2)) { //These lines get the 2 points of the rotated sprite //Given: (x1, y1) starts out as the center point @@ -10086,7 +10127,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, dax = mulscale14(sintable[(spr->ang+256+512)&2047],walldist); day = mulscale14(sintable[(spr->ang+256)&2047],walldist); - if ((x1-(vect->x))*(y2-(vect->y)) >= (x2-(vect->x))*(y1-(vect->y))) //Front + if ((x1-(pos->x))*(y2-(pos->y)) >= (x2-(pos->x))*(y1-(pos->y))) //Front { addclipline(x1+dax,y1+day,x2+day,y2-dax,(int16_t)j+49152); } @@ -10097,9 +10138,9 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, } //Side blocker - if ((x2-x1)*((vect->x)-x1) + (y2-y1)*((vect->y)-y1) < 0) + if ((x2-x1)*((pos->x)-x1) + (y2-y1)*((pos->y)-y1) < 0) { addclipline(x1-day,y1+dax,x1+dax,y1+day,(int16_t)j+49152); } - else if ((x1-x2)*((vect->x)-x2) + (y1-y2)*((vect->y)-y2) < 0) + else if ((x1-x2)*((pos->x)-x2) + (y1-y2)*((pos->y)-y2) < 0) { addclipline(x2+day,y2-dax,x2-dax,y2-day,(int16_t)j+49152); } } } @@ -10107,10 +10148,10 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, case 32: daz = spr->z+ceildist; daz2 = spr->z-flordist; - if (((vect->z) < daz) && ((vect->z) > daz2)) + if (((pos->z) < daz) && ((pos->z) > daz2)) { if ((cstat&64) != 0) - if (((vect->z) > spr->z) == ((cstat&8)==0)) continue; + if (((pos->z) > spr->z) == ((cstat&8)==0)) continue; tilenum = spr->picnum; xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); @@ -10136,23 +10177,23 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, dax = mulscale14(sintable[(spr->ang-256+512)&2047],walldist); day = mulscale14(sintable[(spr->ang-256)&2047],walldist); - if ((rxi[0]-(vect->x))*(ryi[1]-(vect->y)) < (rxi[1]-(vect->x))*(ryi[0]-(vect->y))) + if ((rxi[0]-(pos->x))*(ryi[1]-(pos->y)) < (rxi[1]-(pos->x))*(ryi[0]-(pos->y))) { if (clipinsideboxline(cx,cy,rxi[1],ryi[1],rxi[0],ryi[0],rad) != 0) addclipline(rxi[1]-day,ryi[1]+dax,rxi[0]+dax,ryi[0]+day,(int16_t)j+49152); } - else if ((rxi[2]-(vect->x))*(ryi[3]-(vect->y)) < (rxi[3]-(vect->x))*(ryi[2]-(vect->y))) + else if ((rxi[2]-(pos->x))*(ryi[3]-(pos->y)) < (rxi[3]-(pos->x))*(ryi[2]-(pos->y))) { if (clipinsideboxline(cx,cy,rxi[3],ryi[3],rxi[2],ryi[2],rad) != 0) addclipline(rxi[3]+day,ryi[3]-dax,rxi[2]-dax,ryi[2]-day,(int16_t)j+49152); } - if ((rxi[1]-(vect->x))*(ryi[2]-(vect->y)) < (rxi[2]-(vect->x))*(ryi[1]-(vect->y))) + if ((rxi[1]-(pos->x))*(ryi[2]-(pos->y)) < (rxi[2]-(pos->x))*(ryi[1]-(pos->y))) { if (clipinsideboxline(cx,cy,rxi[2],ryi[2],rxi[1],ryi[1],rad) != 0) addclipline(rxi[2]-dax,ryi[2]-day,rxi[1]-day,ryi[1]+dax,(int16_t)j+49152); } - else if ((rxi[3]-(vect->x))*(ryi[0]-(vect->y)) < (rxi[0]-(vect->x))*(ryi[3]-(vect->y))) + else if ((rxi[3]-(pos->x))*(ryi[0]-(pos->y)) < (rxi[0]-(pos->x))*(ryi[3]-(pos->y))) { if (clipinsideboxline(cx,cy,rxi[0],ryi[0],rxi[3],ryi[3],rad) != 0) addclipline(rxi[0]+dax,ryi[0]+day,rxi[3]+day,ryi[3]-dax,(int16_t)j+49152); @@ -10178,7 +10219,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, do { intx = goalx; inty = goaly; - hitwall = raytrace(vect->x, vect->y, &intx, &inty); + hitwall = raytrace(pos->x, pos->y, &intx, &inty); if (hitwall >= 0) { lx = clipit[hitwall].x2-clipit[hitwall].x1; @@ -10195,6 +10236,8 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, goalx = mulscale20(lx,i)+intx; goaly = mulscale20(ly,i)+inty; } +// else if (tempint2<0) +// Bprintf("!! tempint2<0 !!\n"); tempint1 = dmulscale6(lx,oxvect,ly,oyvect); for (i=cnt+1; i<=clipmoveboxtracenum; i++) @@ -10203,7 +10246,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, tempint2 = dmulscale6(clipit[j].x2-clipit[j].x1,oxvect,clipit[j].y2-clipit[j].y1,oyvect); if ((tempint1^tempint2) < 0) { - updatesector(vect->x,vect->y,sectnum); + updatesector(pos->x,pos->y,sectnum); return(retval); } } @@ -10217,13 +10260,13 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, } cnt--; - vect->x = intx; - vect->y = inty; + pos->x = intx; + pos->y = inty; } while (((xvect|yvect) != 0) && (hitwall >= 0) && (cnt > 0)); for (j=0; jx,vect->y,clipsectorlist[j]) == 1) + if (inside(pos->x,pos->y,clipsectorlist[j]) == 1) { *sectnum = clipsectorlist[j]; return(retval); @@ -10231,12 +10274,12 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, *sectnum = -1; tempint1 = 0x7fffffff; for (j=numsectors-1; j>=0; j--) - if (inside(vect->x,vect->y,j) == 1) + if (inside(pos->x,pos->y,j) == 1) { if (sector[j].ceilingstat&2) - tempint2 = (getceilzofslope((int16_t)j,vect->x,vect->y)-(vect->z)); + tempint2 = (getceilzofslope((int16_t)j,pos->x,pos->y)-(pos->z)); else - tempint2 = (sector[j].ceilingz-(vect->z)); + tempint2 = (sector[j].ceilingz-(pos->z)); if (tempint2 > 0) { @@ -10246,9 +10289,9 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, else { if (sector[j].floorstat&2) - tempint2 = ((vect->z)-getflorzofslope((int16_t)j,vect->x,vect->y)); + tempint2 = ((pos->z)-getflorzofslope((int16_t)j,pos->x,pos->y)); else - tempint2 = ((vect->z)-sector[j].floorz); + tempint2 = ((pos->z)-sector[j].floorz); if (tempint2 <= 0) { @@ -11200,7 +11243,7 @@ void setbrightness(char dabrightness, uint8_t dapalid, char noapply) if ((noapply&1) == 0) setpalette(0,256); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (rendmode >= 3) { static uint32_t lastpalettesum = 0; @@ -11278,7 +11321,7 @@ void clearview(int32_t dacol) if (qsetmode != 200) return; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (rendmode >= 3) { palette_t p = getpal(dacol); @@ -11316,7 +11359,7 @@ void clearallviews(int32_t dacol) if (qsetmode != 200) return; //dacol += (dacol<<8); dacol += (dacol<<16); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (rendmode >= 3) { palette_t p = getpal(dacol); @@ -11346,7 +11389,7 @@ void clearallviews(int32_t dacol) // void plotpixel(int32_t x, int32_t y, char col) { -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (rendmode >= 3 && qsetmode == 200) { palette_t p = getpal(col); @@ -11369,11 +11412,11 @@ void plotpixel(int32_t x, int32_t y, char col) enddrawing(); //}}} } -void plotlines2d(int32_t *xx, int32_t *yy, int32_t numpoints, char col) +void plotlines2d(const int32_t *xx, const int32_t *yy, int32_t numpoints, char col) { int32_t i; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (rendmode >= 3 && qsetmode == 200) { palette_t p = getpal(col); @@ -11393,8 +11436,10 @@ void plotlines2d(int32_t *xx, int32_t *yy, int32_t numpoints, char col) int32_t odrawlinepat = drawlinepat; drawlinepat = 0xffffffff; + begindrawing(); for (i=0; i= 3 && qsetmode == 200) return 0; #endif @@ -11434,7 +11479,7 @@ void setviewtotile(int16_t tilenume, int32_t xsiz, int32_t ysiz) bakframeplace[setviewcnt] = frameplace; frameplace = waloff[tilenume]; bakwindowx1[setviewcnt] = windowx1; bakwindowy1[setviewcnt] = windowy1; bakwindowx2[setviewcnt] = windowx2; bakwindowy2[setviewcnt] = windowy2; -#ifdef POLYMOST +#ifdef USE_OPENGL if (setviewcnt == 0) { bakrendmode = rendmode; @@ -11466,7 +11511,7 @@ void setviewback(void) setviewcnt--; offscreenrendering = (setviewcnt>0); -#ifdef POLYMOST +#ifdef USE_OPENGL if (setviewcnt == 0) { rendmode = bakrendmode; @@ -11542,7 +11587,7 @@ void completemirror(void) int32_t i, dy; intptr_t p; -#ifdef POLYMOST +#ifdef USE_OPENGL if (rendmode) return; #endif @@ -11813,7 +11858,7 @@ void drawline256(int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col) col = palookup[0][col]; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (rendmode >= 3) { palette_t p; @@ -12539,7 +12584,8 @@ void draw2dgrid(int32_t posxe, int32_t posye, int32_t posze, int16_t cursectnum, static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t posze, int32_t zoome) { const walltype *wal = &wall[i]; - int32_t j, x1, y1, x2, y2, dz = 0, dz2 = 0; + int32_t sect=0, j, x1, y1, x2, y2, dz = 0, dz2 = 0; + int32_t fz=0,fzn=0; // intptr_t tempint; char col; @@ -12569,7 +12615,7 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t col = 33; if ((wal->cstat&1) != 0) col = 5; - if (wal->nextwall >= 0 && ((wal->cstat^wall[wal->nextwall].cstat)&1)) + if (wal->nextwall >= 0 && ((wal->cstat^wall[j].cstat)&1)) col = 2; if ((i == linehighlight) || ((linehighlight >= 0) && (i == wall[linehighlight].nextwall))) if (totalclock & 16) @@ -12583,7 +12629,7 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t dy = wal->y-wall[wal->point2].y; dist = dx*dx+dy*dy; - if (dist > 0xffffffff) + if (dist > 0xffffffffll) { col=9; if (i == linehighlight || ((linehighlight >= 0) && (i == wall[linehighlight].nextwall))) @@ -12601,8 +12647,8 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t if (m32_sideview) { // draw vertical line to neighboring wall - int32_t fz, fz2, fzn; - int32_t sect=sectorofwall(i); + int32_t fz2; + sect = sectorofwall(i); fz = getflorzofslope(sect, wal->x,wal->y); fz2 = getflorzofslope(sect, wall[wal->point2].x,wall[wal->point2].y); @@ -12615,12 +12661,13 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t if (wal->nextwall>=0) { - fzn = getflorzofslope(wal->nextsector, wal->x,wal->y)-fz; - drawline16mid(x1,y1, x1,y1+getscreenvdisp(fzn,zoome), editorcolors[col]); + fzn = getflorzofslope(wal->nextsector, wal->x,wal->y); +// if (i < wall[j].point2) + drawline16mid(x1,y1, x1,y1+getscreenvdisp(fzn-fz,zoome), editorcolors[col]); } } - if ((wal->cstat&64) > 0) // if hitscan bit set + if (wal->cstat&64) // if hitscan bit set { int32_t one=(klabs(x2-x1) >= klabs(y2-y1)), no=!one; @@ -12657,18 +12704,11 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t drawline16mid(dax+dax3,day+day3, dax+dax2,day+day2, editorcolors[col]); } - else if (jj > ii) + else { - int32_t dax2 = mulscale11(sintable[(k+1024)&2047],zoome) / 2560; - int32_t day2 = mulscale11(sintable[(k+512)&2047],zoome) / 2560; - - day2 = scalescreeny(day2); - drawline16mid(dax,day, dax+dax2,day+day2, editorcolors[col]); - } - else if (jj < ii) - { - int32_t dax2 = mulscale11(sintable[(k+2048)&2047],zoome) / 2560; - int32_t day2 = mulscale11(sintable[(k+1536)&2047],zoome) / 2560; + int32_t bb = (jj < ii); + int32_t dax2 = mulscale11(sintable[(k+1024 + 1024*bb)&2047],zoome) / 2560; + int32_t day2 = mulscale11(sintable[(k+512 + 1024*bb)&2047],zoome) / 2560; day2 = scalescreeny(day2); drawline16mid(dax,day, dax+dax2,day+day2, editorcolors[col]); @@ -12708,15 +12748,11 @@ static void drawscreen_drawwall(int32_t i, int32_t posxe, int32_t posye, int32_t col = 15; if (m32_sideview) { - int16_t nw = wall[i].nextwall; - if (nw>=0) + if (wal->nextwall >= 0) { - int32_t fz = getflorzofslope(sectorofwall(i), wall[i].x, wall[i].y); - int32_t fz2 = getflorzofslope(wall[i].nextsector, wall[i].x, wall[i].y); - - if (fz < fz2) + if (fz < fzn) col = 7; - else if (fz==fz2) + else if (fz == fzn) col = 4; } } @@ -13147,7 +13183,7 @@ void printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, const if (fontsize) { fontptr = smalltextfont; charxsiz = 4; } else { fontptr = textfont; charxsiz = 8; } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (!polymost_printext256(xpos,ypos,col,backcol,name,fontsize)) return; if (rendmode >= 3 && qsetmode == 200) @@ -13288,7 +13324,7 @@ int32_t screencapture_tga(const char *filename, char inverseit) return -1; } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (rendmode >= 3 && qsetmode == 200) { head[1] = 0; // no colourmap @@ -13313,7 +13349,7 @@ int32_t screencapture_tga(const char *filename, char inverseit) ptr = (char *)frameplace; // palette first -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (rendmode < 3 || (rendmode >= 3 && qsetmode != 200)) { #endif @@ -13324,7 +13360,7 @@ int32_t screencapture_tga(const char *filename, char inverseit) Bfputc(curpalettefaded[i].g, fil); // g Bfputc(curpalettefaded[i].r, fil); // r } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL } #endif @@ -13345,7 +13381,7 @@ int32_t screencapture_tga(const char *filename, char inverseit) } else { -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (rendmode >= 3 && qsetmode == 200) { char c; @@ -13370,7 +13406,7 @@ int32_t screencapture_tga(const char *filename, char inverseit) #endif for (i=ydim-1; i>=0; i--) Bfwrite(ptr+i*bytesperline, xdim, 1, fil); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL } #endif } @@ -13480,7 +13516,7 @@ int32_t screencapture_pcx(const char *filename, char inverseit) head[65] = 1; // 8-bit head[68] = 1; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (rendmode >= 3 && qsetmode == 200) { head[65] = 3; // 24-bit @@ -13519,7 +13555,7 @@ int32_t screencapture_pcx(const char *filename, char inverseit) } else { -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (rendmode >= 3 && qsetmode == 200) { // 24bit @@ -13541,7 +13577,7 @@ int32_t screencapture_pcx(const char *filename, char inverseit) #endif for (i=0; i= 3 && qsetmode != 200)) { #endif @@ -13561,7 +13597,7 @@ int32_t screencapture_pcx(const char *filename, char inverseit) Bfputc(curpalettefaded[i].g, fil); // g Bfputc(curpalettefaded[i].b, fil); // r } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL } #endif @@ -13586,7 +13622,7 @@ int32_t screencapture(const char *filename, char inverseit) int32_t setrendermode(int32_t renderer) { UNREFERENCED_PARAMETER(renderer); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (bpp == 8) renderer = 0; # ifdef POLYMER else renderer = min(4,max(3,renderer)); @@ -13637,7 +13673,7 @@ int32_t setrendermode(int32_t renderer) // // setrollangle // -#ifdef POLYMOST +#ifdef USE_OPENGL void setrollangle(int32_t rolla) { UNREFERENCED_PARAMETER(rolla); @@ -13663,7 +13699,7 @@ void setrollangle(int32_t rolla) // void invalidatetile(int16_t tilenume, int32_t pal, int32_t how) { -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL int32_t numpal, firstpal, np; int32_t hp; @@ -13702,7 +13738,7 @@ void invalidatetile(int16_t tilenume, int32_t pal, int32_t how) // void setpolymost2dview(void) { -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (rendmode < 3) return; if (gloy1 != -1) diff --git a/polymer-perf/eduke32/build/src/hightile.c b/polymer-perf/eduke32/build/src/hightile.c index 435dac2d9..c05b268a6 100644 --- a/polymer-perf/eduke32/build/src/hightile.c +++ b/polymer-perf/eduke32/build/src/hightile.c @@ -4,7 +4,7 @@ * See the included license file "BUILDLIC.TXT" for license info. */ -#ifdef POLYMOST +#ifdef USE_OPENGL #include "build.h" #include "compat.h" diff --git a/polymer-perf/eduke32/build/src/mdsprite.c b/polymer-perf/eduke32/build/src/mdsprite.c index 5197cdc08..d5835cb43 100644 --- a/polymer-perf/eduke32/build/src/mdsprite.c +++ b/polymer-perf/eduke32/build/src/mdsprite.c @@ -1,6 +1,6 @@ //------------------------------------- MD2/MD3 LIBRARY BEGINS ------------------------------------- -#ifdef POLYMOST +#ifdef USE_OPENGL #include "compat.h" #include "build.h" @@ -372,7 +372,7 @@ int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32 return 0; } -int32_t md_definehud(int32_t modelid, int32_t tilex, double xadd, double yadd, double zadd, double angadd, int32_t flags) +int32_t md_definehud(int32_t modelid, int32_t tilex, double xadd, double yadd, double zadd, double angadd, int32_t flags, int32_t fov) { if (!mdinited) mdinit(); @@ -384,6 +384,7 @@ int32_t md_definehud(int32_t modelid, int32_t tilex, double xadd, double yadd, d hudmem[(flags>>2)&1][tilex].zadd = zadd; hudmem[(flags>>2)&1][tilex].angadd = ((int16_t)angadd)|2048; hudmem[(flags>>2)&1][tilex].flags = (int16_t)flags; + hudmem[(flags>>2)&1][tilex].fov = (int16_t)fov; return 0; } @@ -1813,8 +1814,11 @@ int md3postload_polymer(md3model_t *m) surfi++; } - return 1; +#else + UNREFERENCED_PARAMETER(m); #endif + + return 1; } diff --git a/polymer-perf/eduke32/build/src/polymer.c b/polymer-perf/eduke32/build/src/polymer.c index a396ee636..7a2c49781 100644 --- a/polymer-perf/eduke32/build/src/polymer.c +++ b/polymer-perf/eduke32/build/src/polymer.c @@ -1,6 +1,6 @@ // blah -#ifdef POLYMOST +#ifdef USE_OPENGL #define POLYMER_C #include "polymer.h" @@ -31,6 +31,13 @@ int32_t pr_overridespecular = 0; float pr_specularpower = 15.0f; float pr_specularfactor = 1.0f; int32_t pr_highpalookups = 1; +int32_t pr_overridehud = 0; +float pr_hudxadd = 0.0f; +float pr_hudyadd = 0.0f; +float pr_hudzadd = 0.0f; +int32_t pr_hudangadd = 0; +int32_t pr_hudfov = 426; +float pr_overridemodelscale = 0.0f; int32_t pr_ati_fboworkaround = 0; int32_t pr_ati_nodepthoffset = 0; #ifdef __APPLE__ @@ -585,6 +592,8 @@ _prprograminfo prprograms[1 << PR_BIT_COUNT]; int32_t overridematerial; int32_t globaloldoverridematerial; +int32_t rotatespritematerialbits; + // RENDER TARGETS _prrt *prrts; @@ -744,10 +753,23 @@ void polymer_uninit(void) } } -void polymer_glinit(void) +void polymer_setaspect(int32_t ang) { float aspect; + if (pr_customaspect != 0.0f) + aspect = pr_customaspect; + else + aspect = (float)(windowx2-windowx1+1) / + (float)(windowy2-windowy1+1); + + bglMatrixMode(GL_PROJECTION); + bglLoadIdentity(); + bgluPerspective((float)(ang) / (2048.0f / 360.0f), aspect, 0.01f, 100.0f); +} + +void polymer_glinit(void) +{ bglClearColor(0.0f, 0.0f, 0.0f, 1.0f); bglClearStencil(0); bglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); @@ -755,8 +777,6 @@ void polymer_glinit(void) // texturing bglEnable(GL_TEXTURE_2D); - bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); - bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); bglEnable(GL_DEPTH_TEST); bglDepthFunc(GL_LEQUAL); @@ -768,16 +788,8 @@ void polymer_glinit(void) bglPolygonMode(GL_FRONT_AND_BACK, GL_LINE); else bglPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - - if (pr_customaspect != 0.0f) - aspect = pr_customaspect; - else - aspect = (float)(windowx2-windowx1+1) / - (float)(windowy2-windowy1+1); - - bglMatrixMode(GL_PROJECTION); - bglLoadIdentity(); - bgluPerspective((float)(pr_fov) / (2048.0f / 360.0f), aspect, 0.01f, 100.0f); + + polymer_setaspect(pr_fov); bglMatrixMode(GL_MODELVIEW); bglLoadIdentity(); @@ -1199,21 +1211,18 @@ void polymer_editorpick(void) searchit = 0; } -void polymer_rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, - char dapalnum, int32_t dastat, int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2) +void polymer_inb4rotatesprite(int16_t tilenum, char pal, int8_t shade) { - UNREFERENCED_PARAMETER(sx); - UNREFERENCED_PARAMETER(sy); - UNREFERENCED_PARAMETER(z); - UNREFERENCED_PARAMETER(a); - UNREFERENCED_PARAMETER(picnum); - UNREFERENCED_PARAMETER(dashade); - UNREFERENCED_PARAMETER(dapalnum); - UNREFERENCED_PARAMETER(dastat); - UNREFERENCED_PARAMETER(cx1); - UNREFERENCED_PARAMETER(cy1); - UNREFERENCED_PARAMETER(cx2); - UNREFERENCED_PARAMETER(cy2); + _prmaterial rotatespritematerial; + + polymer_getbuildmaterial(&rotatespritematerial, tilenum, pal, shade, 4); + + rotatespritematerialbits = polymer_bindmaterial(rotatespritematerial, NULL, 0); +} + +void polymer_postrotatesprite(void) +{ + polymer_unbindmaterial(rotatespritematerialbits); } void polymer_drawmaskwall(int32_t damaskwallcnt) @@ -2735,7 +2744,7 @@ static void polymer_updatewall(int16_t wallnum) // it also works, bitches sec = §or[sectofwall]; - if (sectofwall < 0 || sectofwall > numsectors || + if (sectofwall < 0 || sectofwall >= numsectors || wallnum < 0 || wallnum > numwalls || sec->wallptr > wallnum || wallnum >= (sec->wallptr + sec->wallnum)) return; // yay, corrupt map @@ -2828,7 +2837,7 @@ static void polymer_updatewall(int16_t wallnum) else xref = 0; - if (wal->nextsector < 0 || wal->nextsector > numsectors) + if (wal->nextsector < 0 || wal->nextsector >= numsectors) { Bmemcpy(w->wall.buffer, &s->floor.buffer[(wallnum - sec->wallptr) * 5], sizeof(GLfloat) * 3); Bmemcpy(&w->wall.buffer[5], &s->floor.buffer[(wal->point2 - sec->wallptr) * 5], sizeof(GLfloat) * 3); @@ -3726,7 +3735,11 @@ static void polymer_drawmdsprite(spritetype *tspr) bglLoadIdentity(); scale = (1.0/4.0); scale *= m->scale; - scale *= m->bscale; + if (pr_overridemodelscale) { + scale *= pr_overridemodelscale; + } else { + scale *= m->bscale; + } if (tspriteptr[MAXSPRITESONSCREEN] == tspr) { float playerang, radplayerang, cosminusradplayerang, sinminusradplayerang, hudzoom; diff --git a/polymer-perf/eduke32/build/src/polymost.c b/polymer-perf/eduke32/build/src/polymost.c index e445ce63d..5e455e7be 100644 --- a/polymer-perf/eduke32/build/src/polymost.c +++ b/polymer-perf/eduke32/build/src/polymost.c @@ -66,7 +66,7 @@ Low priority: **************************************************************************************************/ -#ifdef POLYMOST +#ifdef USE_OPENGL #include "compat.h" #include "build.h" @@ -5279,6 +5279,15 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 x1 = hudmem[(dastat&4)>>2][picnum].xadd; y1 = hudmem[(dastat&4)>>2][picnum].yadd; z1 = hudmem[(dastat&4)>>2][picnum].zadd; + +#ifdef POLYMER + if (pr_overridehud) { + x1 = pr_hudxadd; + y1 = pr_hudyadd; + z1 = pr_hudzadd; + } +#endif + if (!(hudmem[(dastat&4)>>2][picnum].flags&2)) //"NOBOB" is specified in DEF { fx = ((double)sx)*(1.0/65536.0); @@ -5312,6 +5321,12 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 } tspr.ang = hudmem[(dastat&4)>>2][picnum].angadd+globalang; +#ifdef POLYMER + if (pr_overridehud) { + tspr.ang = pr_hudangadd + globalang; + } +#endif + if (dastat&4) { x1 = -x1; y1 = -y1; } // In Polymost, we don't care if the model is very big @@ -5389,6 +5404,8 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 # ifdef POLYMER else { + int32_t fov; + tspriteptr[MAXSPRITESONSCREEN] = &tspr; bglEnable(GL_ALPHA_TEST); @@ -5396,8 +5413,22 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 spriteext[tspr.owner].roll = a; spriteext[tspr.owner].zoff = z; + + fov = hudmem[(dastat&4)>>2][picnum].fov; + + if (fov == -1) { + fov = pr_fov; + } + + if (pr_overridehud) { + fov = pr_hudfov; + } + + polymer_setaspect(fov); polymer_drawsprite(MAXSPRITESONSCREEN); + + polymer_setaspect(pr_fov); spriteext[tspr.owner].zoff = 0; spriteext[tspr.owner].roll = 0; @@ -5454,6 +5485,12 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 bglDisable(GL_DEPTH_TEST); bglDisable(GL_ALPHA_TEST); bglEnable(GL_TEXTURE_2D); + +# ifdef POLYMER + if (rendmode >= 4) { + polymer_inb4rotatesprite(picnum, dapalnum, dashade); + } +# endif } #endif @@ -5607,6 +5644,11 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 #ifdef USE_OPENGL if (rendmode >= 3) { +# ifdef POLYMER + if (rendmode >= 4) { + polymer_postrotatesprite(); + } +# endif bglMatrixMode(GL_PROJECTION); bglPopMatrix(); bglMatrixMode(GL_MODELVIEW); bglPopMatrix(); } @@ -6234,6 +6276,13 @@ void polymost_initosdfuncs(void) { "r_pr_specularpower", "r_pr_specularpower: overriden specular material power", (void *) &pr_specularpower, CVAR_FLOAT | CVAR_NOSAVE, -10, 1000 }, { "r_pr_specularfactor", "r_pr_specularfactor: overriden specular material factor", (void *) &pr_specularfactor, CVAR_FLOAT | CVAR_NOSAVE, -10, 1000 }, { "r_pr_highpalookups", "r_pr_highpalookups: enable/disable highpalookups", (void *) &pr_highpalookups, CVAR_BOOL, 0, 1 }, + { "r_pr_overridehud", "r_pr_overridehud: overrides hud model parameters with values from the pr_hud* cvars; use it to fine-tune DEF tokens", (void *) &pr_overridehud, CVAR_BOOL | CVAR_NOSAVE, 0, 1 }, + { "r_pr_hudxadd", "r_pr_hudxadd: overriden HUD xadd; see r_pr_overridehud", (void *) &pr_hudxadd, CVAR_FLOAT | CVAR_NOSAVE, -100, 100 }, + { "r_pr_hudyadd", "r_pr_hudyadd: overriden HUD yadd; see r_pr_overridehud", (void *) &pr_hudyadd, CVAR_FLOAT | CVAR_NOSAVE, -100, 100 }, + { "r_pr_hudzadd", "r_pr_hudzadd: overriden HUD zadd; see r_pr_overridehud", (void *) &pr_hudzadd, CVAR_FLOAT | CVAR_NOSAVE, -100, 100 }, + { "r_pr_hudangadd", "r_pr_hudangadd: overriden HUD angadd; see r_pr_overridehud", (void *) &pr_hudangadd, CVAR_INT | CVAR_NOSAVE, -512, 512 }, + { "r_pr_hudfov", "r_pr_hudfov: overriden HUD fov; see r_pr_overridehud", (void *) &pr_hudfov, CVAR_INT | CVAR_NOSAVE, 0, 1023 }, + { "r_pr_overridemodelscale", "r_pr_overridemodelscale: overrides model scale if non-zero; use it to fine-tune DEF tokens", (void *) &pr_overridemodelscale, CVAR_FLOAT | CVAR_NOSAVE, 0, 500 }, { "r_pr_ati_fboworkaround", "r_pr_ati_fboworkaround: enable this to workaround an ATI driver bug that causes sprite shadows to be square - you need to restart the renderer for it to take effect", (void *) &pr_ati_fboworkaround, CVAR_BOOL | CVAR_NOSAVE, 0, 1 }, { "r_pr_ati_nodepthoffset", "r_pr_ati_nodepthoffset: enable this to workaround an ATI driver bug that causes sprite drawing to freeze the game on Radeon X1x00 hardware - you need to restart the renderer for it to take effect", (void *) &pr_ati_nodepthoffset, CVAR_BOOL | CVAR_NOSAVE, 0, 1 }, #endif @@ -6350,7 +6399,7 @@ Description of Ken's filter to improve LZW compression of DXT1 format by ~15%: ( I think this improved compression by a few % :) */ -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL int32_t dxtfilter(int32_t fil, texcachepicture *pict, char *pic, void *midbuf, char *packbuf, uint32_t miplen) { void *writebuf; diff --git a/polymer-perf/eduke32/build/src/sdlayer.c b/polymer-perf/eduke32/build/src/sdlayer.c index 00bc29a4f..24a2d40f8 100644 --- a/polymer-perf/eduke32/build/src/sdlayer.c +++ b/polymer-perf/eduke32/build/src/sdlayer.c @@ -202,7 +202,7 @@ int32_t main(int32_t argc, char *argv[]) } } -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL if ((argp = Bgetenv("BUILD_NOFOG")) != NULL) nofog = Batol(argp); #endif @@ -217,7 +217,7 @@ int32_t main(int32_t argc, char *argv[]) return r; } -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL void setvsync(int32_t sync) { if (vsync == sync) return; @@ -303,7 +303,10 @@ int32_t initsystem(void) } else */ - novideo = nogl = 1; + novideo = 1; +#ifdef USE_OPENGL + nogl = 1; +#endif } signal(SIGSEGV, sighandler); @@ -791,18 +794,13 @@ void getvalidmodes(void) #endif 0 }; - static int32_t defaultres[][2] = - { - {1280,1024} - ,{1280,960},{1152,864},{1024,768},{800,600},{640,480}, - {640,400},{512,384},{480,360},{400,300},{320,240},{320,200},{0,0} - }; SDL_Rect **modes; -#if (SDL_MAJOR_VERSION > 1 || SDL_MINOR_VERSION > 2) - SDL_PixelFormat pf = { NULL, 8, 1, 0,0,0,0, 0,0,0,0, 0,0,0,0 }; -#else - SDL_PixelFormat pf = { NULL, 8, 1, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0 }; -#endif + SDL_PixelFormat pf; + + pf.palette = NULL; + pf.BitsPerPixel = 8; + pf.BytesPerPixel = 1; + int32_t i, j, maxx=0, maxy=0; if (modeschecked || novideo) return; @@ -810,20 +808,22 @@ void getvalidmodes(void) validmodecnt=0; // initprintf("Detecting video modes:\n"); -#define ADDMODE(x,y,c,f) if (validmodecnt> 3; modes = SDL_ListModes(&pf, SURFACE_FLAGS -#if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3) +// #if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3) | SDL_FULLSCREEN // not implemented/working in SDL 1.3 SDL_compat.c -#endif +//#endif ); if (modes == (SDL_Rect **)0) @@ -851,15 +851,15 @@ void getvalidmodes(void) if (modes == (SDL_Rect **)-1) { for (i=0; defaultres[i][0]; i++) - ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],1) - } + ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],1); + } else { for (i=0; modes[i]; i++) { if ((modes[i]->w > MAXXDIM) || (modes[i]->h > MAXYDIM)) continue; - ADDMODE(modes[i]->w, modes[i]->h, cdepths[j], 1) + ADDMODE(modes[i]->w, modes[i]->h, cdepths[j], 1); if ((modes[i]->w > maxx) && (modes[i]->h > maxy)) { @@ -885,7 +885,7 @@ void getvalidmodes(void) if (cdepths[j] < 0) continue; for (i=0; defaultres[i][0]; i++) CHECK(defaultres[i][0],defaultres[i][1]) - ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],0) + ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],0); } #undef CHECK @@ -987,7 +987,7 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs) if (lockcount) while (lockcount) enddrawing(); -#if defined(USE_OPENGL) +#ifdef USE_OPENGL if (bpp > 8 && sdl_surface) polymost_glreset(); #endif @@ -998,7 +998,7 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs) gammabrightness = 0; // redetect on next mode switch } -#if defined(USE_OPENGL) +#ifdef USE_OPENGL if (c > 8) { int32_t i, j, multisamplecheck = (glmultisample > 0); diff --git a/polymer-perf/eduke32/build/src/util/ase_import.py b/polymer-perf/eduke32/build/src/util/ase_import.py new file mode 100755 index 000000000..f97e0ce78 --- /dev/null +++ b/polymer-perf/eduke32/build/src/util/ase_import.py @@ -0,0 +1,452 @@ +#!BPY + +""" +Name: 'ASCII Scene (.ase) v0.16' +Blender: 249 +Group: 'Import' +Tooltip: 'ASCII Scene import (*.ase)' +""" +__author__ = "Goofos & Plagman" +__version__ = "0.16" + +# goofos at epruegel.de +# +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ***** END GPL LICENCE BLOCK ***** + +import string, time, sys as osSys +import Blender +from Blender import Draw, Mesh, Window, Object, Scene, NMesh, Key, Ipo, IpoCurve +#import meshtools + + +def read_main(filename): + + global counts + counts = {'verts': 0, 'tris': 0} + + start = time.clock() + file = open(filename, "r") + + print_boxed("----------------start-----------------") + print 'Import Patch: ', filename + + editmode = Window.EditMode() # are we in edit mode? If so ... + if editmode: Window.EditMode(0) # leave edit mode before getting the mesh + + lines= file.readlines() + read_file(file, lines) + + Blender.Window.DrawProgressBar(1.0, '') # clear progressbar + file.close() + print "----------------end-----------------" + end = time.clock() + seconds = " in %.2f %s" % (end-start, "seconds") + totals = "Verts: %i Tris: %i " % (counts['verts'], counts['tris']) + print_boxed(totals) + message = "Successfully imported " + Blender.sys.basename(filename) + seconds + #meshtools.print_boxed(message) + print_boxed(message) + + +def print_boxed(text): #Copy/Paste from meshtools, only to remove the beep :) + lines = text.splitlines() + maxlinelen = max(map(len, lines)) + if osSys.platform[:3] == "win": + print chr(218)+chr(196) + chr(196)*maxlinelen + chr(196)+chr(191) + for line in lines: + print chr(179) + ' ' + line.ljust(maxlinelen) + ' ' + chr(179) + print chr(192)+chr(196) + chr(196)*maxlinelen + chr(196)+chr(217) + else: + print '+-' + '-'*maxlinelen + '-+' + for line in lines: print '| ' + line.ljust(maxlinelen) + ' |' + print '+-' + '-'*maxlinelen + '-+' + #print '\a\r', # beep when done + + +class ase_obj: + + def __init__(self): + self.name = 'Name' + self.objType = None + self.row0x = None + self.row0y = None + self.row0z = None + self.row1x = None + self.row1y = None + self.row1z = None + self.row2x = None + self.row2y = None + self.row2z = None + self.row3x = None + self.row3y = None + self.row3z = None + self.parent = None + self.obj = None + self.objName = 'Name' + +class ase_mesh: + + def __init__(self): + self.name = '' + self.vCount = 0 + self.fCount = 0 + self.frames = [] + self.verts = [] + self.faces = [] + self.animated = 0 + self.frameCount = -1 + +class mesh_vert: + + def __init__(self): + self.x = 0.0 + self.y = 0.0 + self.z = 0.0 + self.u = 0.0 + self.v = 0.0 + self.nx = 0.0 + self.ny = 0.0 + self.nz = 0.0 + self.origi = 0 + def make_tuple(self): + return (self.x, self.y, self.z, self.u, self.v, self.nx, self.ny, self.nz) + +class mesh_face: + + def __init__(self): + self.v1 = mesh_vert() + self.v2 = mesh_vert() + self.v3 = mesh_vert() + self.i1 = 0 + self.i2 = 0 + self.i3 = 0 + +def read_file(file, lines): + + objects = [] + objIdx = 0 + objCheck = -1 #needed to skip helper objects + PBidx = 0.0 + lineCount = float(len(lines)) + processed_indices = [] + curFaceID = 0 + faceVertID = 0 + + print 'Read file' + Blender.Window.DrawProgressBar(0.0, "Read File...") + + for line in lines: + words = string.split(line) + + if (PBidx % 10000) == 0.0: + Blender.Window.DrawProgressBar(PBidx / lineCount, "Read File...") + + if not words: + continue + elif objIdx > 0 and me.animated == 1: + # I don't know how to make empty statements, this is to skip everything else + me.animated = me.animated + elif words[0] == '*GEOMOBJECT': + objCheck = 0 + newObj = ase_obj() + objects.append(newObj) + obj = objects[objIdx] + objIdx += 1 + + obj.objType = 'Mesh' + obj.obj = ase_mesh() + me = obj.obj + elif words[0] == '*NODE_NAME' and objCheck != -1: + if objCheck == 0: + obj.name = words[1] + objCheck = 1 + elif objCheck == 1: + obj.objName = words[1] + elif words[0] == '*TM_ROW0' and objCheck != -1: + obj.row0x = float(words[1]) + obj.row0y = float(words[2]) + obj.row0z = float(words[3]) + elif words[0] == '*TM_ROW1' and objCheck != -1: + obj.row1x = float(words[1]) + obj.row1y = float(words[2]) + obj.row1z = float(words[3]) + elif words[0] == '*TM_ROW2' and objCheck != -1: + obj.row2x = float(words[1]) + obj.row2y = float(words[2]) + obj.row2z = float(words[3]) + elif words[0] == '*TM_ROW3' and objCheck != -1: + obj.row3x = float(words[1]) + obj.row3y = float(words[2]) + obj.row3z = float(words[3]) + objCheck = -1 + elif words[0] == '*MESH_NUMVERTEX': + me.vCount = int(words[1]) + for i in range(me.vCount): + me.verts.append(mesh_vert()) + elif words[0] == '*MESH_NUMFACES': + me.fCount = int(words[1]) + for i in range(me.fCount): + me.faces.append(mesh_face()) + elif words[0] == '*MESH_VERTEX': + i = int(words[1]) + me.verts[i].x = float(words[2]); + me.verts[i].y = float(words[3]); + me.verts[i].z = float(words[4]); + elif words[0] == '*MESH_FACE': + i = int(words[1].rstrip(":")) # looks like "13:" + v1 = int(words[3]); + v2 = int(words[5]); + v3 = int(words[7]); + me.faces[i].v1.x = me.verts[v1].x; + me.faces[i].v1.y = me.verts[v1].y; + me.faces[i].v1.z = me.verts[v1].z; + me.faces[i].v1.origi = v1 + + me.faces[i].v2.x = me.verts[v2].x; + me.faces[i].v2.y = me.verts[v2].y; + me.faces[i].v2.z = me.verts[v2].z; + me.faces[i].v2.origi = v2 + + me.faces[i].v3.x = me.verts[v3].x; + me.faces[i].v3.y = me.verts[v3].y; + me.faces[i].v3.z = me.verts[v3].z; + me.faces[i].v3.origi = v3 + elif words[0] == '*MESH_NUMTVERTEX': + del me.verts[:] + uvCount = int(words[1]) + for i in range(uvCount): + me.verts.append(mesh_vert()) + elif words[0] == '*MESH_TVERT': + i = int(words[1]) + me.verts[i].u = float(words[2]); + me.verts[i].v = float(words[3]); + elif words[0] == '*MESH_TFACE': + i = int(words[1]) + uv1 = int(words[2]); + uv2 = int(words[3]); + uv3 = int(words[4]); + + me.faces[i].v1.u = me.verts[uv1].u; + me.faces[i].v1.v = me.verts[uv1].v; + + me.faces[i].v2.u = me.verts[uv2].u; + me.faces[i].v2.v = me.verts[uv2].v; + + me.faces[i].v3.u = me.verts[uv3].u; + me.faces[i].v3.v = me.verts[uv3].v; + elif words[0] == '*MESH_FACENORMAL': + curFaceID = int(words[1]) # global, vertexnormal needs this + faceVertID = 0 # same + elif words[0] == '*MESH_VERTEXNORMAL': + nx = float(words[2]) + ny = float(words[3]) + nz = float(words[4]) + + if (faceVertID == 0): + me.faces[curFaceID].v1.nx = nx; + me.faces[curFaceID].v1.ny = ny; + me.faces[curFaceID].v1.nz = nz; + elif (faceVertID == 1): + me.faces[curFaceID].v2.nx = nx; + me.faces[curFaceID].v2.ny = ny; + me.faces[curFaceID].v2.nz = nz; + elif (faceVertID == 2): + me.faces[curFaceID].v3.nx = nx; + me.faces[curFaceID].v3.ny = ny; + me.faces[curFaceID].v3.nz = nz; + + faceVertID = faceVertID + 1; + elif words[0] == '*MESH_ANIMATION': + me.animated = 1 + + # now the loop for animation frames + if objIdx > 0 and me.animated == 1: + if words[0] == '*MESH_VERTEX_LIST': + me.frameCount += 1 + me.frames.append([]) + elif words[0] == '*MESH_VERTEX': + me.frames[me.frameCount].append(mesh_vert()) + i = int(words[1]) + me.frames[me.frameCount][i].x = float(words[2]); + me.frames[me.frameCount][i].y = float(words[3]); + me.frames[me.frameCount][i].z = float(words[4]); + + PBidx += 1.0 + + spawn_main(objects) + + Blender.Redraw() + +def spawn_main(objects): + + PBidx = 0.0 + objCount = float(len(objects)) + + print 'Import Objects' + Blender.Window.DrawProgressBar(0.0, "Importing Objects...") + + for obj in objects: + + Blender.Window.DrawProgressBar(PBidx / objCount, "Importing Objects...") + + if obj.objType == 'Mesh': + spawn_mesh(obj) + + PBidx += 1.0 + +import random + +def spawn_mesh(obj): + + objMe = obj.obj + #normal_flag = 1 + + row0 = obj.row0x, obj.row0y, obj.row0z + row1 = obj.row1x, obj.row1y, obj.row1z + row2 = obj.row2x, obj.row2y, obj.row2z + row3 = obj.row3x, obj.row3y, obj.row3z + + newMatrix = Blender.Mathutils.Matrix(row0, row1, row2, row3) + newMatrix.resize4x4() + + newObj = Blender.Object.New(obj.objType, obj.name) + newObj.setMatrix(newMatrix) + Blender.Scene.getCurrent().link(newObj) + + + newMesh = Blender.Mesh.New(obj.objName) + newMesh.getFromObject(newObj.name) + + newMesh.vertexUV = 1 + newObj.link(newMesh) + + del objMe.verts[:] + objMe.vCount = 0 + + vertDict = {} + + #for face in objMe.faces: + #objMe.verts.append(face.v1) + #objMe.verts.append(face.v2) + #objMe.verts.append(face.v3) + #face.i1 = objMe.vCount + #objMe.vCount = objMe.vCount + 1 + #face.i2 = objMe.vCount + #objMe.vCount = objMe.vCount + 1 + #face.i3 = objMe.vCount + #objMe.vCount = objMe.vCount + 1 + + for face in objMe.faces: + if not face.v1.make_tuple() in vertDict: + vertDict[face.v1.make_tuple()] = objMe.vCount + objMe.verts.append(face.v1) + objMe.vCount = objMe.vCount + 1 + if not face.v2.make_tuple() in vertDict: + vertDict[face.v2.make_tuple()] = objMe.vCount + objMe.verts.append(face.v2) + objMe.vCount = objMe.vCount + 1 + if not face.v3.make_tuple() in vertDict: + vertDict[face.v3.make_tuple()] = objMe.vCount + objMe.verts.append(face.v3) + objMe.vCount = objMe.vCount + 1 + face.i1 = vertDict[face.v1.make_tuple()] + face.i2 = vertDict[face.v2.make_tuple()] + face.i3 = vertDict[face.v3.make_tuple()] + + # Verts + for i in range(objMe.vCount): + xyz = Blender.Mathutils.Vector(objMe.verts[i].x, objMe.verts[i].y, objMe.verts[i].z) + newMesh.verts.extend(xyz) + + for i in range(objMe.vCount): + xyz = Blender.Mathutils.Vector(objMe.verts[i].x, objMe.verts[i].y, objMe.verts[i].z) + uv = Blender.Mathutils.Vector(objMe.verts[i].u, objMe.verts[i].v) + norm = Blender.Mathutils.Vector(objMe.verts[i].nx, objMe.verts[i].ny, objMe.verts[i].nz) + newMesh.verts[i].co = xyz; + newMesh.verts[i].uvco = uv; + newMesh.verts[i].no = norm; + + if objMe.animated: + objMe.frameCount -= 1 # do we always get an extra frame at the end? + for frame in objMe.frames: + for i in range(objMe.vCount): + xyz = Blender.Mathutils.Vector(frame[objMe.verts[i].origi].x, frame[objMe.verts[i].origi].y, frame[objMe.verts[i].origi].z) + + newMesh.verts[i].co = xyz; + newObj.insertShapeKey() + + for key in Key.Get() : + key.ipo = Ipo.New('Key', "bleh" + "_ipo") + index = 1 + for curveName in key.ipo.curveConsts : + # print curveName + key.ipo.addCurve(curveName) + key.ipo[curveName].interpolation = IpoCurve.InterpTypes.CONST + key.ipo[curveName].addBezier((0, 0)) + key.ipo[curveName].addBezier((index, 1)) + key.ipo[curveName].addBezier((index + 1, 0)) + index+=1 + + # Faces + for i in range(objMe.fCount): + face = [objMe.faces[i].i1, objMe.faces[i].i2, objMe.faces[i].i3] + newMesh.faces.extend(face) + + # UV + #if guiTable['UV'] == 1 and objMe.hasFUV == 1: + #newMesh.faceUV = 1 + #for f in objMe.uvFaces: + #uv1 = Blender.Mathutils.Vector(float(objMe.uvVerts[f.uv1].u), float(objMe.uvVerts[f.uv1].v)) + #uv2 = Blender.Mathutils.Vector(float(objMe.uvVerts[f.uv2].u), float(objMe.uvVerts[f.uv2].v)) + #uv3 = Blender.Mathutils.Vector(float(objMe.uvVerts[f.uv3].u), float(objMe.uvVerts[f.uv3].v)) + #newMesh.faces[f.index].uv = [uv1, uv2, uv3] + ## normals + #vertices = [coords for n, coords in sorted(objMe.normals)] + + #random.seed() + + #i = 0 + #for v in newMesh.verts: + #no = Blender.Mathutils.Vector(vertices[i][0], vertices[i][1], vertices[i][2]) + #v.no = no + #print 'vertice ', i, 'normal : ', v.no + ##v.no[0] = vertices[i][0] + ##v.no[1] = vertices[i][1] + ##v.no[2] = vertices[i][2] + #i = i + 1 + + newMesh.transform((newObj.getMatrix('worldspace').invert()), 1) + + Blender.Set("curframe", objMe.frameCount + 1) + + counts['verts'] += objMe.vCount + counts['tris'] += objMe.fCount + print 'Imported Mesh-Object: ', obj.name + + + +def read_ui(filename): + Window.WaitCursor(1) + + read_main(filename) + + Window.WaitCursor(0) + + +Blender.Window.FileSelector(read_ui, "Import ASE") \ No newline at end of file diff --git a/polymer-perf/eduke32/build/src/util/md3_export.py b/polymer-perf/eduke32/build/src/util/md3_export.py new file mode 100644 index 000000000..6a21e4513 --- /dev/null +++ b/polymer-perf/eduke32/build/src/util/md3_export.py @@ -0,0 +1,1219 @@ +#!BPY + +""" +Name: 'Quake3 (.md3)...' +Blender: 242 +Group: 'Export' +Tooltip: 'Export to Quake3 file format. (.md3)' +""" +__author__ = "PhaethonH, Bob Holcomb, Damien McGinnes, Robert (Tr3B) Beckebans" +__url__ = ("http://xreal.sourceforge.net") +__version__ = "0.7 2006-11-12" + +__bpydoc__ = """\ +This script exports a Quake3 file (MD3). + +Supported:
+ Surfaces, Materials and Tags. + +Missing:
+ None. + +Known issues:
+ None. + +Notes:
+ TODO +""" + +import sys, os, os.path, struct, string, math + +import Blender +from Blender import * +from Blender.Draw import * +from Blender.BGL import * +from Blender.Window import * + +import types + +import textwrap + +import logging +reload(logging) + +import sys, struct, string, math +from types import * + +import os +from os import path + +GAMEDIR = 'D:/Games/XreaL_testing/base/' +#GAMEDIR = '/opt/XreaL/base/' +MAX_QPATH = 64 + +import sys, struct, string, math +from types import * + +import os +from os import path + +import q_shared +from q_shared import * + +MD3_IDENT = "IDP3" +MD3_VERSION = 15 +MD3_MAX_TAGS = 16 +MD3_MAX_SURFACES = 32 +MD3_MAX_FRAMES = 1024 +MD3_MAX_SHADERS = 256 +MD3_MAX_VERTICES = 4096 +MD3_MAX_TRIANGLES = 8192 +MD3_XYZ_SCALE = (1.0 / 64.0) +MD3_BLENDER_SCALE = (1.0 / 1.0) + + +class md3Vert: + xyz = [] + normal = 0 + binaryFormat = "<3hh" + + def __init__(self): + self.xyz = [0, 0, 0] + self.normal = 0 + + def GetSize(self): + return struct.calcsize(self.binaryFormat) + + # copied from PhaethonH md3.py + def Decode(self, latlng): + lat = (latlng >> 8) & 0xFF; + lng = (latlng) & 0xFF; + lat *= math.pi / 128; + lng *= math.pi / 128; + x = math.cos(lat) * math.sin(lng) + y = math.sin(lat) * math.sin(lng) + z = math.cos(lng) + retval = [ x, y, z ] + return retval + + # copied from PhaethonH md3.py + def Encode(self, normal): + x, y, z = normal + + # normalise + l = math.sqrt((x*x) + (y*y) + (z*z)) + if l == 0: + return 0 + x = x/l + y = y/l + z = z/l + + if (x == 0.0) & (y == 0.0) : + if z > 0.0: + return 0 + else: + return (128 << 8) + + # Encode a normal vector into a 16-bit latitude-longitude value + #lng = math.acos(z) + #lat = math.acos(x / math.sin(lng)) + #retval = ((lat & 0xFF) << 8) | (lng & 0xFF) + lng = math.acos(z) * 255 / (2 * math.pi) + lat = math.atan2(y, x) * 255 / (2 * math.pi) + retval = ((int(lat) & 0xFF) << 8) | (int(lng) & 0xFF) + return retval + + def Load(self, file): + tmpData = file.read(struct.calcsize(self.binaryFormat)) + data = struct.unpack(self.binaryFormat, tmpData) + self.xyz[0] = data[0] * MD3_XYZ_SCALE + self.xyz[1] = data[1] * MD3_XYZ_SCALE + self.xyz[2] = data[2] * MD3_XYZ_SCALE + self.normal = data[3] + return self + + def Save(self, file): + tmpData = [0] * 4 + tmpData[0] = self.xyz[0] / MD3_XYZ_SCALE + tmpData[1] = self.xyz[1] / MD3_XYZ_SCALE + tmpData[2] = self.xyz[2] / MD3_XYZ_SCALE + tmpData[3] = self.normal + data = struct.pack(self.binaryFormat, tmpData[0], tmpData[1], tmpData[2], tmpData[3]) + file.write(data) + #print "Wrote MD3 Vertex: ", data + + def Dump(self): + log.info("MD3 Vertex") + log.info("X: %s", self.xyz[0]) + log.info("Y: %s", self.xyz[1]) + log.info("Z: %s", self.xyz[2]) + log.info("Normal: %s", self.normal) + log.info("") + +class md3TexCoord: + u = 0.0 + v = 0.0 + + binaryFormat = "<2f" + + def __init__(self): + self.u = 0.0 + self.v = 0.0 + + def GetSize(self): + return struct.calcsize(self.binaryFormat) + + def Load(self, file): + tmpData = file.read(struct.calcsize(self.binaryFormat)) + data = struct.unpack(self.binaryFormat, tmpData) + # for some reason quake3 texture maps are upside down, flip that + self.u = data[0] + self.v = 1.0 - data[1] + return self + + def Save(self, file): + tmpData = [0] * 2 + tmpData[0] = self.u + tmpData[1] = 1.0 - self.v + data = struct.pack(self.binaryFormat, tmpData[0], tmpData[1]) + file.write(data) + #print "wrote MD3 texture coordinate structure: ", data + + def Dump(self): + log.info("MD3 Texture Coordinates") + log.info("U: %s", self.u) + log.info("V: %s", self.v) + log.info("") + + +class md3Triangle: + indexes = [] + + binaryFormat = "<3i" + + def __init__(self): + self.indexes = [ 0, 0, 0 ] + + def GetSize(self): + return struct.calcsize(self.binaryFormat) + + def Load(self, file): + tmpData = file.read(struct.calcsize(self.binaryFormat)) + data = struct.unpack(self.binaryFormat, tmpData) + self.indexes[0] = data[0] + self.indexes[1] = data[2] # reverse + self.indexes[2] = data[1] # reverse + return self + + def Save(self, file): + tmpData = [0] * 3 + tmpData[0] = self.indexes[0] + tmpData[1] = self.indexes[2] # reverse + tmpData[2] = self.indexes[1] # reverse + data = struct.pack(self.binaryFormat,tmpData[0], tmpData[1], tmpData[2]) + file.write(data) + #print "wrote MD3 face structure: ",data + + def Dump(self, log): + log.info("MD3 Triangle") + log.info("Indices: %s", self.indexes) + log.info("") + + +class md3Shader: + name = "" + index = 0 + + binaryFormat = "<%dsi" % MAX_QPATH + + def __init__(self): + self.name = "" + self.index = 0 + + def GetSize(self): + return struct.calcsize(self.binaryFormat) + + def Load(self, file): + tmpData = file.read(struct.calcsize(self.binaryFormat)) + data = struct.unpack(self.binaryFormat, tmpData) + self.name = asciiz(data[0]) + self.index = data[1] + return self + + def Save(self, file): + tmpData = [0] * 2 + tmpData[0] = self.name + tmpData[1] = self.index + data = struct.pack(self.binaryFormat, tmpData[0], tmpData[1]) + file.write(data) + #print "wrote MD3 shader structure: ",data + + def Dump(self, log): + log.info("MD3 Shader") + log.info("Name: %s", self.name) + log.info("Index: %s", self.index) + log.info("") + + +class md3Surface: + ident = "" + name = "" + flags = 0 + numFrames = 0 + numShaders = 0 + numVerts = 0 + numTriangles = 0 + ofsTriangles = 0 + ofsShaders = 0 + ofsUV = 0 + ofsVerts = 0 + ofsEnd = 0 + shaders = [] + triangles = [] + uv = [] + verts = [] + + binaryFormat = "<4s%ds10i" % MAX_QPATH # 1 int, name, then 10 ints + + def __init__(self): + self.ident = "" + self.name = "" + self.flags = 0 + self.numFrames = 0 + self.numShaders = 0 + self.numVerts = 0 + self.numTriangles = 0 + self.ofsTriangles = 0 + self.ofsShaders = 0 + self.ofsUV = 0 + self.ofsVerts = 0 + self.ofsEnd + self.shaders = [] + self.triangles = [] + self.uv = [] + self.verts = [] + + def GetSize(self): + sz = struct.calcsize(self.binaryFormat) + self.ofsTriangles = sz + for t in self.triangles: + sz += t.GetSize() + self.ofsShaders = sz + for s in self.shaders: + sz += s.GetSize() + self.ofsUV = sz + for u in self.uv: + sz += u.GetSize() + self.ofsVerts = sz + for v in self.verts: + sz += v.GetSize() + self.ofsEnd = sz + return self.ofsEnd + + def Load(self, file, log): + # where are we in the file (for calculating real offsets) + ofsBegin = file.tell() + tmpData = file.read(struct.calcsize(self.binaryFormat)) + data = struct.unpack(self.binaryFormat, tmpData) + self.ident = data[0] + self.name = asciiz(data[1]) + self.flags = data[2] + self.numFrames = data[3] + self.numShaders = data[4] + self.numVerts = data[5] + self.numTriangles = data[6] + self.ofsTriangles = data[7] + self.ofsShaders = data[8] + self.ofsUV = data[9] + self.ofsVerts = data[10] + self.ofsEnd = data[11] + + # load the tri info + file.seek(ofsBegin + self.ofsTriangles, 0) + for i in range(0, self.numTriangles): + self.triangles.append(md3Triangle()) + self.triangles[i].Load(file) + #self.triangles[i].Dump(log) + + # load the shader info + file.seek(ofsBegin + self.ofsShaders, 0) + for i in range(0, self.numShaders): + self.shaders.append(md3Shader()) + self.shaders[i].Load(file) + #self.shaders[i].Dump(log) + + # load the uv info + file.seek(ofsBegin + self.ofsUV, 0) + for i in range(0, self.numVerts): + self.uv.append(md3TexCoord()) + self.uv[i].Load(file) + #self.uv[i].Dump(log) + + # load the verts info + file.seek(ofsBegin + self.ofsVerts, 0) + for i in range(0, self.numFrames): + for j in range(0, self.numVerts): + self.verts.append(md3Vert()) + #i*self.numVerts+j=where in the surface vertex list the vert position for this frame is + self.verts[(i * self.numVerts) + j].Load(file) + #self.verts[j].Dump(log) + + # go to the end of this structure + file.seek(ofsBegin+self.ofsEnd, 0) + + return self + + def Save(self, file): + self.GetSize() + tmpData = [0] * 12 + tmpData[0] = self.ident + tmpData[1] = self.name + tmpData[2] = self.flags + tmpData[3] = self.numFrames + tmpData[4] = self.numShaders + tmpData[5] = self.numVerts + tmpData[6] = self.numTriangles + tmpData[7] = self.ofsTriangles + tmpData[8] = self.ofsShaders + tmpData[9] = self.ofsUV + tmpData[10] = self.ofsVerts + tmpData[11] = self.ofsEnd + data = struct.pack(self.binaryFormat, tmpData[0],tmpData[1],tmpData[2],tmpData[3],tmpData[4],tmpData[5],tmpData[6],tmpData[7],tmpData[8],tmpData[9],tmpData[10],tmpData[11]) + file.write(data) + + # write the tri data + for t in self.triangles: + t.Save(file) + + # save the shader coordinates + for s in self.shaders: + s.Save(file) + + # save the uv info + for u in self.uv: + u.Save(file) + + # save the verts + for v in self.verts: + v.Save(file) + + def Dump(self, log): + log.info("MD3 Surface") + log.info("Ident: %s", self.ident) + log.info("Name: %s", self.name) + log.info("Flags: %s", self.flags) + log.info("Number of Frames: %s", self.numFrames) + log.info("Number of Shaders: %s", self.numShaders) + log.info("Number of Verts: %s", self.numVerts) + log.info("Number of Triangles: %s", self.numTriangles) + log.info("Offset to Triangles: %s", self.ofsTriangles) + log.info("Offset to Shaders: %s", self.ofsShaders) + log.info("Offset to UV: %s", self.ofsUV) + log.info("Offset to Verts: %s", self.ofsVerts) + log.info("Offset to end: %s", self.ofsEnd) + log.info("") + + +class md3Tag: + name = "" + origin = [] + axis = [] + + binaryFormat="<%ds3f9f" % MAX_QPATH + + def __init__(self): + self.name = "" + self.origin = [0, 0, 0] + self.axis = [0, 0, 0, 0, 0, 0, 0, 0, 0] + + def GetSize(self): + return struct.calcsize(self.binaryFormat) + + def Load(self, file): + tmpData = file.read(struct.calcsize(self.binaryFormat)) + data = struct.unpack(self.binaryFormat, tmpData) + self.name = asciiz(data[0]) + self.origin[0] = data[1] + self.origin[1] = data[2] + self.origin[2] = data[3] + self.axis[0] = data[4] + self.axis[1] = data[5] + self.axis[2] = data[6] + self.axis[3] = data[7] + self.axis[4] = data[8] + self.axis[5] = data[9] + self.axis[6] = data[10] + self.axis[7] = data[11] + self.axis[8] = data[12] + return self + + def Save(self, file): + tmpData = [0] * 13 + tmpData[0] = self.name + tmpData[1] = float(self.origin[0]) + tmpData[2] = float(self.origin[1]) + tmpData[3] = float(self.origin[2]) + tmpData[4] = float(self.axis[0]) + tmpData[5] = float(self.axis[1]) + tmpData[6] = float(self.axis[2]) + tmpData[7] = float(self.axis[3]) + tmpData[8] = float(self.axis[4]) + tmpData[9] = float(self.axis[5]) + tmpData[10] = float(self.axis[6]) + tmpData[11] = float(self.axis[7]) + tmpData[12] = float(self.axis[8]) + data = struct.pack(self.binaryFormat, tmpData[0],tmpData[1],tmpData[2],tmpData[3],tmpData[4],tmpData[5],tmpData[6], tmpData[7], tmpData[8], tmpData[9], tmpData[10], tmpData[11], tmpData[12]) + file.write(data) + #print "wrote MD3 Tag structure: ",data + + def Dump(self, log): + log.info("MD3 Tag") + log.info("Name: %s", self.name) + log.info("Origin: %s", self.origin) + log.info("Axis: %s", self.axis) + log.info("") + +class md3Frame: + mins = 0 + maxs = 0 + localOrigin = 0 + radius = 0.0 + name = "" + + binaryFormat="<3f3f3ff16s" + + def __init__(self): + self.mins = [0, 0, 0] + self.maxs = [0, 0, 0] + self.localOrigin = [0, 0, 0] + self.radius = 0.0 + self.name = "" + + def GetSize(self): + return struct.calcsize(self.binaryFormat) + + def Load(self, file): + tmpData = file.read(struct.calcsize(self.binaryFormat)) + data = struct.unpack(self.binaryFormat, tmpData) + self.mins[0] = data[0] + self.mins[1] = data[1] + self.mins[2] = data[2] + self.maxs[0] = data[3] + self.maxs[1] = data[4] + self.maxs[2] = data[5] + self.localOrigin[0] = data[6] + self.localOrigin[1] = data[7] + self.localOrigin[2] = data[8] + self.radius = data[9] + self.name = asciiz(data[10]) + return self + + def Save(self, file): + tmpData = [0] * 11 + tmpData[0] = self.mins[0] + tmpData[1] = self.mins[1] + tmpData[2] = self.mins[2] + tmpData[3] = self.maxs[0] + tmpData[4] = self.maxs[1] + tmpData[5] = self.maxs[2] + tmpData[6] = self.localOrigin[0] + tmpData[7] = self.localOrigin[1] + tmpData[8] = self.localOrigin[2] + tmpData[9] = self.radius + tmpData[10] = self.name + data = struct.pack(self.binaryFormat, tmpData[0],tmpData[1],tmpData[2],tmpData[3],tmpData[4],tmpData[5],tmpData[6],tmpData[7], tmpData[8], tmpData[9], tmpData[10]) + file.write(data) + #print "wrote MD3 frame structure: ",data + + def Dump(self, log): + log.info("MD3 Frame") + log.info("Min Bounds: %s", self.mins) + log.info("Max Bounds: %s", self.maxs) + log.info("Local Origin: %s", self.localOrigin) + log.info("Radius: %s", self.radius) + log.info("Name: %s", self.name) + log.info("") + +class md3Object: + # header structure + ident = "" # this is used to identify the file (must be IDP3) + version = 0 # the version number of the file (Must be 15) + name = "" + flags = 0 + numFrames = 0 + numTags = 0 + numSurfaces = 0 + numSkins = 0 + ofsFrames = 0 + ofsTags = 0 + ofsSurfaces = 0 + ofsEnd = 0 + frames = [] + tags = [] + surfaces = [] + + binaryFormat="<4si%ds9i" % MAX_QPATH # little-endian (<), 17 integers (17i) + + def __init__(self): + self.ident = 0 + self.version = 0 + self.name = "" + self.flags = 0 + self.numFrames = 0 + self.numTags = 0 + self.numSurfaces = 0 + self.numSkins = 0 + self.ofsFrames = 0 + self.ofsTags = 0 + self.ofsSurfaces = 0 + self.ofsEnd = 0 + self.frames = [] + self.tags = [] + self.surfaces = [] + + def GetSize(self): + self.ofsFrames = struct.calcsize(self.binaryFormat) + self.ofsTags = self.ofsFrames + for f in self.frames: + self.ofsTags += f.GetSize() + self.ofsSurfaces += self.ofsTags + for t in self.tags: + self.ofsSurfaces += t.GetSize() + self.ofsEnd = self.ofsSurfaces + for s in self.surfaces: + self.ofsEnd += s.GetSize() + return self.ofsEnd + + def Load(self, file, log): + tmpData = file.read(struct.calcsize(self.binaryFormat)) + data = struct.unpack(self.binaryFormat, tmpData) + + self.ident = data[0] + self.version = data[1] + + if(self.ident != "IDP3" or self.version != 15): + log.error("Not a valid MD3 file") + log.error("Ident: %s", self.ident) + log.error("Version: %s", self.version) + Exit() + + self.name = asciiz(data[2]) + self.flags = data[3] + self.numFrames = data[4] + self.numTags = data[5] + self.numSurfaces = data[6] + self.numSkins = data[7] + self.ofsFrames = data[8] + self.ofsTags = data[9] + self.ofsSurfaces = data[10] + self.ofsEnd = data[11] + + # load the frame info + file.seek(self.ofsFrames, 0) + for i in range(0, self.numFrames): + self.frames.append(md3Frame()) + self.frames[i].Load(file) + #self.frames[i].Dump(log) + + # load the tags info + file.seek(self.ofsTags, 0) + for i in range(0, self.numFrames): + for j in range(0, self.numTags): + tag = md3Tag() + tag.Load(file) + #tag.Dump(log) + self.tags.append(tag) + + # load the surface info + file.seek(self.ofsSurfaces, 0) + for i in range(0, self.numSurfaces): + self.surfaces.append(md3Surface()) + self.surfaces[i].Load(file, log) + self.surfaces[i].Dump(log) + return self + + def Save(self, file): + self.GetSize() + tmpData = [0] * 12 + tmpData[0] = self.ident + tmpData[1] = self.version + tmpData[2] = self.name + tmpData[3] = self.flags + tmpData[4] = self.numFrames + tmpData[5] = self.numTags + tmpData[6] = self.numSurfaces + tmpData[7] = self.numSkins + tmpData[8] = self.ofsFrames + tmpData[9] = self.ofsTags + tmpData[10] = self.ofsSurfaces + tmpData[11] = self.ofsEnd + + data = struct.pack(self.binaryFormat, tmpData[0],tmpData[1],tmpData[2],tmpData[3],tmpData[4],tmpData[5],tmpData[6],tmpData[7], tmpData[8], tmpData[9], tmpData[10], tmpData[11]) + file.write(data) + + for f in self.frames: + f.Save(file) + + for t in self.tags: + t.Save(file) + + for s in self.surfaces: + s.Save(file) + + def Dump(self, log): + log.info("Header Information") + log.info("Ident: %s", self.ident) + log.info("Version: %s", self.version) + log.info("Name: %s", self.name) + log.info("Flags: %s", self.flags) + log.info("Number of Frames: %s",self.numFrames) + log.info("Number of Tags: %s", self.numTags) + log.info("Number of Surfaces: %s", self.numSurfaces) + log.info("Number of Skins: %s", self.numSkins) + log.info("Offset Frames: %s", self.ofsFrames) + log.info("Offset Tags: %s", self.ofsTags) + log.info("Offset Surfaces: %s", self.ofsSurfaces) + log.info("Offset end: %s", self.ofsEnd) + log.info("") + +def asciiz(s): + n = 0 + while(ord(s[n]) != 0): + n = n + 1 + return s[0:n] + +# strips the slashes from the back of a string +def StripPath(path): + for c in range(len(path), 0, -1): + if path[c-1] == "/" or path[c-1] == "\\": + path = path[c:] + break + return path + +# strips the model from path +def StripModel(path): + for c in range(len(path), 0, -1): + if path[c-1] == "/" or path[c-1] == "\\": + path = path[:c] + break + return path + +# strips file type extension +def StripExtension(name): + n = 0 + best = len(name) + while(n != -1): + n = name.find('.',n+1) + if(n != -1): + best = n + name = name[0:best] + return name + +# strips gamedir +def StripGamePath(name): + gamepath = GAMEDIR.replace( '\\', '/' ) + namepath = name.replace( '\\', '/' ) + if namepath[0:len(gamepath)] == gamepath: + namepath= namepath[len(gamepath):len(namepath)] + return namepath + +import sys, struct, string, math + +def ANGLE2SHORT(x): + return int((x * 65536 / 360) & 65535) + +def SHORT2ANGLE(x): + return x * (360.0 / 65536.0) + +def DEG2RAD(a): + return (a * math.pi) / 180.0 + +def RAD2DEG(a): + return (a * 180.0) / math.pi + +def DotProduct(x, y): + return x[0] * y[0] + x[1] * y[1] + x[2] * y[2] + +def CrossProduct(a,b): + return [a[1]*b[2] - a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0]] + +def VectorLength(v): + return math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]) + +def VectorSubtract(a, b): + return [a[0] - b[0], a[1] - b[1], a[2] - b[2]] + +def VectorAdd(a, b): + return [a[0] + b[0], a[1] + b[1], a[2] + b[2]] + +def VectorCopy(v): + return [v[0], v[1], v[2]] + +def VectorInverse(v): + return [-v[0], -v[1], -v[2]] + +#define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2]) +#define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s)) +#define VectorMA(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s)) + +def RadiusFromBounds(mins, maxs): + corner = [0, 0, 0] + a = 0 + b = 0 + + for i in range(0, 3): + a = abs(mins[i]) + b = abs(maxs[i]) + if a > b: + corner[i] = a + else: + corner[i] = b + + return VectorLength(corner) + + +# NOTE: Tr3B - matrix is in column-major order +def MatrixIdentity(): + return [[1.0, 0.0, 0.0, 0.0], + [0.0, 1.0, 0.0, 0.0], + [0.0, 0.0, 1.0, 0.0], + [0.0, 0.0, 0.0, 1.0]] + +def MatrixFromAngles(pitch, yaw, roll): + sp = math.sin(DEG2RAD(pitch)) + cp = math.cos(DEG2RAD(pitch)) + + sy = math.sin(DEG2RAD(yaw)) + cy = math.cos(DEG2RAD(yaw)) + + sr = math.sin(DEG2RAD(roll)) + cr = math.cos(DEG2RAD(roll)) + +# return [[cp * cy, (sr * sp * cy + cr * -sy), (cr * sp * cy + -sr * -sy), 0.0], +# [cp * sy, (sr * sp * sy + cr * cy), (cr * sp * sy + -sr * cy), 0.0], +# [-sp, sr * cp, cr * cp, 0.0], +# [0.0, 0.0, 0.0, 1.0]] + + return [[cp * cy, cp * sy, -sp, 0.0], + [(sr * sp * cy + cr * -sy), (sr * sp * sy + cr * cy), sr * cp, 0.0], + [(cr * sp * cy + -sr * -sy), (cr * sp * sy + -sr * cy), cr * cp, 0.0], + [0.0, 0.0, 0.0, 1.0]] + +def MatrixTransformPoint(m, p): + return [m[0][0] * p[0] + m[1][0] * p[1] + m[2][0] * p[2] + m[3][0], + m[0][1] * p[0] + m[1][1] * p[1] + m[2][1] * p[2] + m[3][1], + m[0][2] * p[0] + m[1][2] * p[1] + m[2][2] * p[2] + m[3][2]] + + +def MatrixTransformNormal(m, p): + return [m[0][0] * p[0] + m[1][0] * p[1] + m[2][0] * p[2], + m[0][1] * p[0] + m[1][1] * p[1] + m[2][1] * p[2], + m[0][2] * p[0] + m[1][2] * p[1] + m[2][2] * p[2]] + +def MatrixMultiply(b, a): + return [[ + a[0][0] * b[0][0] + a[0][1] * b[1][0] + a[0][2] * b[2][0], + a[0][0] * b[0][1] + a[0][1] * b[1][1] + a[0][2] * b[2][1], + a[0][0] * b[0][2] + a[0][1] * b[1][2] + a[0][2] * b[2][2], + 0.0, + ],[ + a[1][0] * b[0][0] + a[1][1] * b[1][0] + a[1][2] * b[2][0], + a[1][0] * b[0][1] + a[1][1] * b[1][1] + a[1][2] * b[2][1], + a[1][0] * b[0][2] + a[1][1] * b[1][2] + a[1][2] * b[2][2], + 0.0, + ],[ + a[2][0] * b[0][0] + a[2][1] * b[1][0] + a[2][2] * b[2][0], + a[2][0] * b[0][1] + a[2][1] * b[1][1] + a[2][2] * b[2][1], + a[2][0] * b[0][2] + a[2][1] * b[1][2] + a[2][2] * b[2][2], + 0.0, + ],[ + a[3][0] * b[0][0] + a[3][1] * b[1][0] + a[3][2] * b[2][0] + b[3][0], + a[3][0] * b[0][1] + a[3][1] * b[1][1] + a[3][2] * b[2][1] + b[3][1], + a[3][0] * b[0][2] + a[3][1] * b[1][2] + a[3][2] * b[2][2] + b[3][2], + 1.0, + ]] + +def MatrixSetupTransform(forward, left, up, origin): + return [[forward[0], forward[1], forward[2], origin[0]], + [left[0], left[1], left[2], origin[1]], + [up[0], up[1], up[2], origin[2]], + [0.0, 0.0, 0.0, 1.0]] + +# our own logger class. it works just the same as a normal logger except +# all info messages get show. +class Logger(logging.Logger): + def __init__(self, name,level = logging.NOTSET): + logging.Logger.__init__(self, name, level) + + self.has_warnings = False + self.has_errors = False + self.has_critical = False + + def info(self, msg, *args, **kwargs): + apply(self._log,(logging.INFO, msg, args), kwargs) + + def warning(self, msg, *args, **kwargs): + logging.Logger.warning(self, msg, *args, **kwargs) + self.has_warnings = True + + def error(self, msg, *args, **kwargs): + logging.Logger.error(self, msg, *args, **kwargs) + self.has_errors = True + + def critical(self, msg, *args, **kwargs): + logging.Logger.critical(self, msg, *args, **kwargs) + self.has_errors = True + +# should be able to make this print to stdout in realtime and save MESSAGES +# as well. perhaps also have a log to file option +class LogHandler(logging.StreamHandler): + def __init__(self): + logging.StreamHandler.__init__(self, sys.stdout) + + if "md3_export_log" not in Blender.Text.Get(): + self.outtext = Blender.Text.New("md3_export_log") + else: + self.outtext = Blender.Text.Get('md3_export_log') + self.outtext.clear() + + self.lastmsg = '' + + def emit(self, record): + # print to stdout and to a new blender text object + msg = self.format(record) + + if msg == self.lastmsg: + return + + self.lastmsg = msg + self.outtext.write("%s\n" %msg) + + logging.StreamHandler.emit(self, record) + +logging.setLoggerClass(Logger) +log = logging.getLogger('md3_export') + +handler = LogHandler() +formatter = logging.Formatter('%(levelname)s %(message)s') +handler.setFormatter(formatter) + +log.addHandler(handler) +# set this to minimum output level. eg. logging.DEBUG, logging.WARNING, logging.ERROR +# logging.CRITICAL. logging.INFO will make little difference as these always get +# output'd +log.setLevel(logging.WARNING) + + +class BlenderGui: + def __init__(self): + text = """A log has been written to a blender text window. Change this window type to +a text window and you will be able to select the file md3_export_log.""" + + text = textwrap.wrap(text,40) + text += [''] + + if log.has_critical: + text += ['There were critical errors!!!!'] + + elif log.has_errors: + text += ['There were errors!'] + + elif log.has_warnings: + text += ['There were warnings'] + + # add any more text before here + text.reverse() + + self.msg = text + + Blender.Draw.Register(self.gui, self.event, self.button_event) + + def gui(self,): + quitbutton = Blender.Draw.Button("Exit", 1, 0, 0, 100, 20, "Close Window") + + y = 35 + + for line in self.msg: + BGL.glRasterPos2i(10,y) + Blender.Draw.Text(line) + y+=15 + + def event(self,evt, val): + if evt == Blender.Draw.ESCKEY: + Blender.Draw.Exit() + return + + def button_event(self,evt): + if evt == 1: + Blender.Draw.Exit() + return + + +def ApplyTransform(vert, matrix): + return vert * matrix + + +def UpdateFrameBounds(v, f): + for i in range(0, 3): + f.mins[i] = min(v[i], f.mins[i]) + for i in range(0, 3): + f.maxs[i] = max(v[i], f.maxs[i]) + + +def UpdateFrameRadius(f): + f.radius = RadiusFromBounds(f.mins, f.maxs) + + +def ProcessSurface(scene, blenderObject, md3, pathName, modelName): + # because md3 doesnt suppoort faceUVs like blender, we need to duplicate + # any vertex that has multiple uv coords + + vertDict = {} + indexDict = {} # maps a vertex index to the revised index after duplicating to account for uv + vertList = [] # list of vertices ordered by revised index + numVerts = 0 + uvList = [] # list of tex coords ordered by revised index + faceList = [] # list of faces (they index into vertList) + numFaces = 0 + + scene.makeCurrent() + Blender.Set("curframe", 1) + Blender.Window.Redraw() + + # get the object (not just name) and the Mesh, not NMesh + mesh = blenderObject.getData(False, True) + matrix = blenderObject.getMatrix('worldspace') + + surf = md3Surface() + surf.numFrames = md3.numFrames + surf.name = blenderObject.getName() + surf.ident = MD3_IDENT + + # create shader for surface + surf.shaders.append(md3Shader()) + surf.numShaders += 1 + surf.shaders[0].index = 0 + + log.info("Materials: %s", mesh.materials) + # :P + #shaderpath=Blender.Draw.PupStrInput("shader path for "+blenderObject.name+":", "", MAX_QPATH ) + shaderpath="" + if shaderpath == "" : + if not mesh.materials: + surf.shaders[0].name = pathName + blenderObject.name + else: + surf.shaders[0].name = pathName + mesh.materials[0].name + else: + if not mesh.materials: + surf.shaders[0].name = shaderpath + blenderObject.name + else: + surf.shaders[0].name = shaderpath + mesh.materials[0].name + + # process each face in the mesh + for face in mesh.faces: + + tris_in_this_face = [] #to handle quads and up... + + # this makes a list of indices for each tri in this face. a quad will be [[0,1,1],[0,2,3]] + for vi in range(1, len(face.v)-1): + tris_in_this_face.append([0, vi, vi + 1]) + + # loop across each tri in the face, then each vertex in the tri + for this_tri in tris_in_this_face: + numFaces += 1 + tri = md3Triangle() + tri_ind = 0 + for i in this_tri: + # get the vertex index, coords and uv coords + index = face.v[i].index + v = face.v[i].co + if mesh.faceUV == True: + uv = (face.uv[i][0], face.uv[i][1]) + elif mesh.vertexUV: + uv = (face.v[i].uvco[0], face.v[i].uvco[1]) + else: + uv = (0.0, 0.0) # handle case with no tex coords + + + if vertDict.has_key((index, uv)): + # if we've seen this exact vertex before, simply add it + # to the tris list of vertex indices + tri.indexes[tri_ind] = vertDict[(index, uv)] + else: + # havent seen this tri before + # (or its uv coord is different, so we need to duplicate it) + + vertDict[(index, uv)] = numVerts + + # put the uv coord into the list + # (uv coord are directly related to each vertex) + tex = md3TexCoord() + tex.u = uv[0] + tex.v = uv[1] + uvList.append(tex) + + tri.indexes[tri_ind] = numVerts + + # now because we have created a new index, + # we need a way to link it to the index that + # blender returns for NMVert.index + if indexDict.has_key(index): + # already there - each of the entries against + # this key represents the same vertex with a + # different uv value + ilist = indexDict[index] + ilist.append(numVerts) + indexDict[index] = ilist + else: + # this is a new one + indexDict[index] = [numVerts] + + numVerts += 1 + tri_ind +=1 + faceList.append(tri) + + # we're done with faces and uv coords + for t in uvList: + surf.uv.append(t) + + for f in faceList: + surf.triangles.append(f) + + surf.numTriangles = len(faceList) + surf.numVerts = numVerts + + # now vertices are stored as frames - + # all vertices for frame 1, all vertices for frame 2...., all vertices for frame n + # so we need to iterate across blender's frames, and copy out each vertex + for frameNum in range(1, md3.numFrames + 1): + Blender.Set("curframe", frameNum) + Blender.Window.Redraw() + + m = NMesh.GetRawFromObject(blenderObject.name) + + vlist = [0] * numVerts + for vertex in m.verts: + try: + vindices = indexDict[vertex.index] + except: + log.warning("Found a vertex in %s that is not part of a face", blenderObject.name) + continue + + vTx = ApplyTransform(vertex.co, matrix) + nTx = ApplyTransform(vertex.no, matrix) + UpdateFrameBounds(vTx, md3.frames[frameNum - 1]) + vert = md3Vert() + #vert.xyz = vertex.co[0:3] + #vert.normal = vert.Encode(vertex.no[0:3]) + vert.xyz = vTx[0:3] + vert.normal = vert.Encode(vertex.no[0:3]) + #print vertex.no + for ind in vindices: # apply the position to all the duplicated vertices + vlist[ind] = vert + + UpdateFrameRadius(md3.frames[frameNum - 1]) + + for vl in vlist: + surf.verts.append(vl) + + surf.Dump(log) + md3.surfaces.append(surf) + md3.numSurfaces += 1 + + +def Export(fileName): + if(fileName.find('.md3', -4) <= 0): + fileName += '.md3' + + log.info("Starting ...") + + log.info("Exporting MD3 format to: %s", fileName) + + pathName = StripGamePath(StripModel(fileName)) + log.info("Shader path name: %s", pathName) + + modelName = StripExtension(StripPath(fileName)) + log.info("Model name: %s", modelName) + + md3 = md3Object() + md3.ident = MD3_IDENT + md3.version = MD3_VERSION + + tagList = [] + + # get the scene + scene = Blender.Scene.getCurrent() + context = scene.getRenderingContext() + + scene.makeCurrent() + md3.numFrames = Blender.Get("curframe") + Blender.Set("curframe", 1) + + # create a bunch of blank frames, they'll be filled in by 'ProcessSurface' + for i in range(1, md3.numFrames + 1): + frame = md3Frame() + frame.name = "frame_" + str(i) + md3.frames.append(frame) + + # export all selected objects + objlist = Blender.Object.GetSelected() + + # process each object for the export + for obj in objlist: + # check if it's a mesh object + if obj.getType() == "Mesh": + log.info("Processing surface: %s", obj.name) + if len(md3.surfaces) == MD3_MAX_SURFACES: + log.warning("Hit md3 limit (%i) for number of surfaces, skipping ...", MD3_MAX_SURFACES, obj.getName()) + else: + ProcessSurface(scene, obj, md3, pathName, modelName) + elif obj.getType() == "Empty": # for tags, we just put em in a list so we can process them all together + if obj.name[0:4] == "tag_": + log.info("Processing tag: %s", obj.name) + tagList.append(obj) + md3.numTags += 1 + else: + log.info("Skipping object: %s", obj.name) + + + # work out the transforms for the tags for each frame of the export + for i in range(1, md3.numFrames + 1): + + # needed to update IPO's value, but probably not the best way for that... + scene.makeCurrent() + Blender.Set("curframe", i) + Blender.Window.Redraw() + for tag in tagList: + t = md3Tag() + matrix = tag.getMatrix('worldspace') + t.origin[0] = matrix[3][0] + t.origin[1] = matrix[3][1] + t.origin[2] = matrix[3][2] + + t.axis[0] = matrix[0][0] + t.axis[1] = matrix[0][1] + t.axis[2] = matrix[0][2] + + t.axis[3] = matrix[1][0] + t.axis[4] = matrix[1][1] + t.axis[5] = matrix[1][2] + + t.axis[6] = matrix[2][0] + t.axis[7] = matrix[2][1] + t.axis[8] = matrix[2][2] + t.name = tag.name + #t.Dump(log) + md3.tags.append(t) + + # export! + file = open(fileName, "wb") + md3.Save(file) + file.close() + md3.Dump(log) + +def FileSelectorCallback(fileName): + Export(fileName) + + BlenderGui() + +Blender.Window.FileSelector(FileSelectorCallback, "Export Quake3 MD3") \ No newline at end of file diff --git a/polymer-perf/eduke32/build/src/winlayer.c b/polymer-perf/eduke32/build/src/winlayer.c index 27288b469..5639d623f 100644 --- a/polymer-perf/eduke32/build/src/winlayer.c +++ b/polymer-perf/eduke32/build/src/winlayer.c @@ -22,7 +22,7 @@ #include #include -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL #include "glbuild.h" #endif @@ -60,7 +60,7 @@ int32_t backgroundidle = 1; static WORD sysgamma[3][256]; extern int32_t curbrightness, gammabrightness; -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL // OpenGL stuff static HGLRC hGLRC = 0; char nofog=0; @@ -464,7 +464,7 @@ int32_t WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, in *stderr = *fp; } -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL if ((argp = Bgetenv("BUILD_NOFOG")) != NULL) nofog = Batol(argp); if (Bgetenv("BUILD_FORCEGL") != NULL) @@ -594,7 +594,7 @@ static void win_printversion(void) if (largepagesavailable) initprintf("Large page support available\n"); #else - initprintf(nedhandle ? "w/ nedmalloc.dll\n" : "\n"); + initprintf(nedhandle ? "\nInitialized nedmalloc\n" : "\n"); #endif } @@ -626,7 +626,7 @@ int32_t initsystem(void) win_printversion(); -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL if (loadgldriver(getenv("BUILD_GLDRV"))) { initprintf("Failure loading OpenGL. GL modes are unavailable.\n"); @@ -658,7 +658,7 @@ void uninitsystem(void) win_allowtaskswitching(1); -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL unloadgldriver(); #endif @@ -1688,7 +1688,7 @@ int32_t checkvideomode(int32_t *x, int32_t *y, int32_t c, int32_t fs, int32_t fo // setvideomode() -- set the video mode // -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL static HWND hGLWindow = NULL; #endif @@ -1738,7 +1738,7 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs) if (gammabrightness && setgamma() < 0) gammabrightness = 0; } -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL if (hGLWindow && glinfo.vsync) bwglSwapIntervalEXT(vsync); #endif if (inp) AcquireInputDevices(1); @@ -1767,7 +1767,7 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs) #define CHECK(w,h) if ((w < maxx) && (h < maxy)) -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL void setvsync(int32_t sync) { if (!glinfo.vsync) @@ -1857,16 +1857,11 @@ static int32_t sortmodes(const struct validmode_t *a, const struct validmode_t * } void getvalidmodes(void) { - static int32_t defaultres[][2] = - { - {1920,1440},{1920,1200},{1600,1200},{1280,1024},{1280,960},{1152,864},{1024,768},{1024,600},{800,600},{640,480}, - {640,400},{512,384},{480,360},{400,300},{320,240},{320,200},{0,0} - }; int32_t cdepths[2] = { 8, 0 }; int32_t i, j, maxx=0, maxy=0; HRESULT result; -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL if (desktopbpp > 8 && !nogl) cdepths[1] = desktopbpp; else cdepths[1] = 0; #endif @@ -1892,7 +1887,7 @@ void getvalidmodes(void) } } } -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL cdsenummodes(); #endif @@ -2002,7 +1997,7 @@ void showframe(int32_t w) char *p,*q; int32_t i,j; -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL if (bpp > 8) { if (palfadedelta) @@ -2680,7 +2675,7 @@ static int32_t SetupDIB(int32_t width, int32_t height) return FALSE; } -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL // // ReleaseOpenGL() -- cleans up OpenGL rendering stuff // @@ -2907,7 +2902,7 @@ static int32_t SetupOpenGL(int32_t width, int32_t height, int32_t bitspp) // support bgra textures glinfo.bgra = 1; } - else if (!Bstrcmp((char *)p2, "GL_ARB_texture_compression")) + else if (!Bstrcmp((char *)p2, "GL_ARB_texture_compression") && Bstrcmp(glinfo.vendor,"ATI Technologies Inc.")) { // support texture compression glinfo.texcompr = 1; @@ -3016,7 +3011,7 @@ static BOOL CreateAppWindow(int32_t modenum) { if (bpp > 8) { -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL ReleaseOpenGL(); #endif } @@ -3029,7 +3024,7 @@ static BOOL CreateAppWindow(int32_t modenum) { // restore previous display mode and set to normal cooperative level RestoreDirectDrawMode(); -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL } else if (fs && fullscreen) { @@ -3121,7 +3116,7 @@ static BOOL CreateAppWindow(int32_t modenum) { if (bitspp > 8) { -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL // yes, start up opengl if (SetupOpenGL(width,height,bitspp)) return TRUE; @@ -3146,7 +3141,7 @@ static BOOL CreateAppWindow(int32_t modenum) return TRUE; } -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL if (bitspp > 8) { DEVMODE dmScreenSettings; @@ -3200,7 +3195,7 @@ static BOOL CreateAppWindow(int32_t modenum) if (bitspp > 8) { -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL // we want an opengl mode if (SetupOpenGL(width,height,bitspp)) { @@ -3218,7 +3213,7 @@ static BOOL CreateAppWindow(int32_t modenum) } } -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL if (bitspp > 8) loadglextensions(); #endif @@ -3255,7 +3250,7 @@ static void DestroyAppWindow(void) gammabrightness = 0; } -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL UninitOpenGL(); #endif UninitDirectDraw(); @@ -3566,7 +3561,7 @@ static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPA POINT pt; HRESULT result; */ -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (hWnd == hGLWindow) return DefWindowProc(hWnd,uMsg,wParam,lParam); #endif @@ -3585,7 +3580,7 @@ static LRESULT CALLBACK WndProcCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPA case WM_ACTIVATEAPP: { appactive = wParam; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (hGLWindow) { if (!appactive && fullscreen) diff --git a/polymer-perf/eduke32/eduke32.vcxproj b/polymer-perf/eduke32/eduke32.vcxproj index d32e84b1b..49ecf215a 100644 --- a/polymer-perf/eduke32/eduke32.vcxproj +++ b/polymer-perf/eduke32/eduke32.vcxproj @@ -120,6 +120,7 @@ + diff --git a/polymer-perf/eduke32/eduke32.vcxproj.filters b/polymer-perf/eduke32/eduke32.vcxproj.filters index a2e13546f..0a92d2d8e 100644 --- a/polymer-perf/eduke32/eduke32.vcxproj.filters +++ b/polymer-perf/eduke32/eduke32.vcxproj.filters @@ -354,6 +354,9 @@ eduke32\headers + + eduke32\headers + diff --git a/polymer-perf/eduke32/nedmalloc.dll b/polymer-perf/eduke32/nedmalloc.dll index ceca0169b..4952fe2bf 100644 Binary files a/polymer-perf/eduke32/nedmalloc.dll and b/polymer-perf/eduke32/nedmalloc.dll differ diff --git a/polymer-perf/eduke32/samples/a.m32 b/polymer-perf/eduke32/samples/a.m32 index 64aeffe60..860be045d 100644 --- a/polymer-perf/eduke32/samples/a.m32 +++ b/polymer-perf/eduke32/samples/a.m32 @@ -24,16 +24,15 @@ define SFACTORSTEPS 100 define PREVIEW_DRAW_COLOR 11 gamevar showpal 0 0 -// 2d mode corruption checker interval, 120 = 1 second -gamevar checkinterval 1200 0 - // whether to use overridden aspect/range values when entering 3d mode (software/Polymost). // tweak with keys 7,8,9,0 on the top row gamevar use_custom_aspect 0 0 // this is now the same as r_usenewaspect gamevar davr 65536 0 gamevar dayx 65536 0 -// see end of file for user key defs + +// see end of file for more user settings and examples + ////////// END USER SETTINGS ////////// @@ -72,18 +71,6 @@ definequote LIGHTQUOTE light %d %d %d %d %d %d %d %d %d %d %d %d %d %d // sec range radius fade ang horiz prio tile -// Corruption checker -definequote 19 PANIC!!! SECTOR OR WALL LIMIT EXCEEDED!!! -definequote 20 SECTOR[%d].WALLPTR=%d out of range: numwalls=%d -definequote 21 SECTOR[%d].WALLPTR=%d inconsistent, expected %d -definequote 22 SECTOR[%d]: wallptr+wallnum=%d out of range: numwalls=%d -definequote 23 WALL[%d].POINT2=%d out of range [%d, %d] -definequote 24 WALL[%d].NEXTWALL=%d out of range: numwalls=%d -definequote 25 WALL[%d].NEXTSECTOR=%d out of range: numsectors=%d -definequote 26 SPRITE[%d].SECTNUM=%d. Expect problems! -definequote 27 SPRITE[%d].PICNUM=%d out of range, resetting to 0 -definequote 28 WALL[%d] has nextsector but no nextwall or vice versa! - define PRSCALE 1000 define MAXSPECULAR 100000 @@ -393,7 +380,9 @@ defstate fiddlewithlights } ends -defstate userkeys_3d ends // forward-ref +// forward refs +defstate userkeys_3d ends +defstate userdrawlabel ends onevent EVENT_PREKEYS3D // state testkeyavail @@ -1009,124 +998,29 @@ defstate js // jump to current sprite updatecursectnum ends -defstate jumptosec // (tmp) - ifge tmp 0 ifl tmp numsectors nullop else return - set j sector[tmp].wallptr - set posx wall[j].x - set posy wall[j].y +var sec 0 0 +var wal 0 0 + +defstate jumptowal // (wal) + ifge wal 0 ifl wal numwalls nullop else return + set posx wall[wal].x + set posy wall[wal].y updatecursectnum ends -// Map corruption checker -// now included in Mapster32 natively - -/* -defstate corruptchk - var ewall - var endwall - var ok - - ifle numsectors MAXSECTORS ifle numwalls MAXWALLS nullop else - { quote 19 printmessage16 19 return } - - set ok 1 - - set ewall 0 // expected wall index - for i allsectors - { - set k 1 - ifge sector[i].wallptr 0 ifl sector[i].wallptr numwalls nullop else - { - qsprintf TQUOTE 20 i sector[i].wallptr numwalls - quote TQUOTE printmessage16 TQUOTE - set k 0 - } - ifn ewall sector[i].wallptr - { - qsprintf TQUOTE 21 i sector[i].wallptr ewall - quote TQUOTE printmessage16 TQUOTE - set ewall sector[i].wallptr - } - add ewall sector[i].wallnum - - set endwall sector[i].wallptr add endwall sector[i].wallnum - ifg endwall numwalls - { - qsprintf TQUOTE 22 i endwall numwalls - quote TQUOTE printmessage16 TQUOTE - set k 0 - } - - and ok k - - ifn k 0 - { - sub endwall 1 - for j wallsofsector i - { - ifge wall[j].point2 sector[i].wallptr ifle wall[i].point2 endwall nullop else - { - qsprintf TQUOTE 23 j wall[j].point2 sector[i].wallptr endwall - quote TQUOTE printmessage16 TQUOTE - set ok 0 - } - - ifge wall[j].nextwall numwalls - { - qsprintf TQUOTE 24 j wall[j].nextwall numwalls - quote TQUOTE printmessage16 TQUOTE - set ok 0 - } - - ifge wall[j].nextsector numsectors - { - qsprintf TQUOTE 25 j wall[j].nextsector numsectors - quote TQUOTE printmessage16 TQUOTE - set ok 0 - } - - set k 0 - ifge wall[j].nextsector 0, xor k 1 - ifge wall[j].nextwall 0, xor k 1 - - ife k 1 - { - qsprintf TQUOTE 28 j - quote TQUOTE printmessage16 TQUOTE - set ok 0 - } - } - } - } - - for i allsprites - { - ifl .sectnum 0 - { - qsprintf TQUOTE 26 i .sectnum - quote TQUOTE printmessage16 TQUOTE - set ok 0 - } - - ifge .picnum 0 ifl .picnum MAXTILES nullop else - { - qsprintf TQUOTE 27 i .picnum - quote TQUOTE printmessage16 TQUOTE - set .picnum 0 - set ok 0 - } - } - - ife ok 0 - print "--" +defstate jumptosec // (sec) + ifge sec 0 ifl sec numsectors nullop else return + set wal sector[sec].wallptr + state jumptowal ends -*/ -gamevar d2d_lastcheck 0 0 + onevent EVENT_DRAW2DSCREEN var tmp var xx + state userdrawlabel + ifge cursectnum 0 { state connectlocators @@ -1135,14 +1029,6 @@ onevent EVENT_DRAW2DSCREEN state previewdoors2d - ifl checkinterval 120, set checkinterval 120 - set tmp totalclock, sub tmp checkinterval - ifl d2d_lastcheck tmp - { - set d2d_lastcheck totalclock -// state corruptchk - } - ifn showpal 0 { set xx 100 @@ -1237,7 +1123,23 @@ defstate chselshade ends -////////// USER KEY SETTINGS ////////// +////////// USER AREA ////////// + +// key settings defstate userkeys_3d ifholdkey KEY_SEMI ifhitkey KEY_C state chselshade ends + +/* +// example for custom labels +defstate userdrawlabel + for i allsprites + { + ifactor 2978 + { + qsprintf TQUOTE "MOVABLE EX:%d OW:%d", sprite[i].owner, sprite[i].extra + drawlabel TQUOTE .x .y .z 0 31 + } + } +ends +*/ diff --git a/polymer-perf/eduke32/samples/tests.m32 b/polymer-perf/eduke32/samples/tests.m32 index 34f410e75..d804746d8 100644 --- a/polymer-perf/eduke32/samples/tests.m32 +++ b/polymer-perf/eduke32/samples/tests.m32 @@ -152,3 +152,26 @@ defstate consttest qsprintf TQUOTE "%d %d %d %d" -2147483648 MIN_CONSTANT i j quote TQUOTE, quote " " ends + +defstate anmtest + var yo + + for i range MAXTILES + { + set j tilesizx[i], or j tilesizy[i] + + ifn j 0 + { + set yo picanm[i] + shiftl yo 8, shiftr yo 24 // sign-extend + + ifl yo 0, inv yo + + ifge yo tilesizy[i] + { + qsprintf TQUOTE "Tile %d's y offset >= y size" i + quote TQUOTE + } + } + } +ends diff --git a/polymer-perf/eduke32/source/actors.c b/polymer-perf/eduke32/source/actors.c index 2d8280f81..3e40ec692 100644 --- a/polymer-perf/eduke32/source/actors.c +++ b/polymer-perf/eduke32/source/actors.c @@ -33,8 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # define ACTOR_STATIC static #endif - -#define KILLIT(KX) {deletesprite(KX);goto BOLT;} +#define KILLIT(KX) { deletesprite(KX); goto BOLT; } extern int32_t g_numEnvSoundsPlaying; extern int32_t g_noEnemies; @@ -894,16 +893,16 @@ int32_t A_IncurDamage(int32_t sn) if (A_CheckSpriteTileFlags(actor[sn].picnum,SPRITE_PROJECTILE) && (SpriteProjectile[sn].workslike & PROJECTILE_RPG)) { - g_player[p].ps->posvel.x += + g_player[p].ps->vel.x += actor[sn].extra*(sintable[(actor[sn].ang+512)&2047])<<2; - g_player[p].ps->posvel.y += + g_player[p].ps->vel.y += actor[sn].extra*(sintable[actor[sn].ang&2047])<<2; } else if (A_CheckSpriteTileFlags(actor[sn].picnum,SPRITE_PROJECTILE)) { - g_player[p].ps->posvel.x += + g_player[p].ps->vel.x += actor[sn].extra*(sintable[(actor[sn].ang+512)&2047])<<1; - g_player[p].ps->posvel.y += + g_player[p].ps->vel.y += actor[sn].extra*(sintable[actor[sn].ang&2047])<<1; } @@ -916,15 +915,15 @@ int32_t A_IncurDamage(int32_t sn) case SEENINE__STATIC: case OOZFILTER__STATIC: case EXPLODINGBARREL__STATIC: - g_player[p].ps->posvel.x += + g_player[p].ps->vel.x += actor[sn].extra*(sintable[(actor[sn].ang+512)&2047])<<2; - g_player[p].ps->posvel.y += + g_player[p].ps->vel.y += actor[sn].extra*(sintable[actor[sn].ang&2047])<<2; break; default: - g_player[p].ps->posvel.x += + g_player[p].ps->vel.x += actor[sn].extra*(sintable[(actor[sn].ang+512)&2047])<<1; - g_player[p].ps->posvel.y += + g_player[p].ps->vel.y += actor[sn].extra*(sintable[actor[sn].ang&2047])<<1; break; } @@ -1282,7 +1281,7 @@ ACTOR_STATIC void G_MoveFallers(void) s->z -= (16<<8); T2 = s->ang; x = s->extra; - IFHIT + if ((j = A_IncurDamage(i)) >= 0) { if (j == FIREEXT || j == RPG || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER) { @@ -1540,7 +1539,7 @@ ACTOR_STATIC void G_MoveStandables(void) { p = A_FindPlayer(s,&x); - IFHIT + if ((j = A_IncurDamage(i)) >= 0) { if (s->owner == -2) if (g_player[p].ps->on_crane == i) @@ -1692,7 +1691,7 @@ ACTOR_STATIC void G_MoveStandables(void) x = s->extra; s->extra = 1; l = s->ang; - IFHIT { actor[i].t_data[6] = 3; + if ((j = A_IncurDamage(i)) >= 0) { actor[i].t_data[6] = 3; T3 = 16; } s->extra = x; @@ -2061,7 +2060,7 @@ DETONATE: case TRASH__STATIC: if (s->xvel == 0) s->xvel = 1; - IFMOVING + if (A_SetSprite(i, CLIPMASK0)) { A_Fall(i); if (krand()&1) s->zvel -= 256; @@ -2283,7 +2282,7 @@ CLEAR_THE_BOLT: case CANWITHSOMETHING3__STATIC: case CANWITHSOMETHING4__STATIC: A_Fall(i); - IFHIT + if ((j = A_IncurDamage(i)) >= 0) { A_PlaySound(VENT_BUST,i); @@ -2497,7 +2496,7 @@ ACTOR_STATIC void G_MoveWeapons(void) } if (!(SpriteProjectile[i].workslike & PROJECTILE_BOUNCESOFFWALLS) && - s->yvel >= 0 && sprite[s->yvel].sectnum < MAXSECTORS) + s->yvel >= 0 && sprite[s->yvel].sectnum != MAXSECTORS) if (FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256) j = 49152|s->yvel; @@ -2914,7 +2913,7 @@ ACTOR_STATIC void G_MoveWeapons(void) if (s->picnum == COOLEXPLOSION1) { if ((j&49152) == 49152 && sprite[j&(MAXSPRITES-1)].picnum != APLAYER) - goto BOLT; + goto COOLEXPLOSION; s->xvel = 0; s->zvel = 0; } @@ -3086,6 +3085,7 @@ ACTOR_STATIC void G_MoveWeapons(void) } if (s->picnum == COOLEXPLOSION1) { +COOLEXPLOSION: s->shade++; if (s->shade >= 40) KILLIT(i); } @@ -3215,7 +3215,7 @@ ACTOR_STATIC void G_MoveTransports(void) if (onfloorz && sectlotag == 1 && g_player[p].ps->on_ground && g_player[p].ps->pos.z >= sector[sect].floorz && - (TEST_SYNC_KEY(g_player[p].sync->bits, SK_CROUCH) || g_player[p].ps->posvel.z > 2048)) + (TEST_SYNC_KEY(g_player[p].sync->bits, SK_CROUCH) || g_player[p].ps->vel.z > 2048)) // if( onfloorz && sectlotag == 1 && g_player[p].ps->pos.z > (sector[sect].floorz-(6<<8)) ) { k = 1; @@ -3230,14 +3230,14 @@ ACTOR_STATIC void G_MoveTransports(void) sector[sprite[OW].sectnum].ceilingz; /* - g_player[p].ps->posvel.x = 4096-(krand()&8192); - g_player[p].ps->posvel.y = 4096-(krand()&8192); + g_player[p].ps->vel.x = 4096-(krand()&8192); + g_player[p].ps->vel.y = 4096-(krand()&8192); */ if (TEST_SYNC_KEY(g_player[p].sync->bits, SK_CROUCH)) - g_player[p].ps->posvel.z += 512; + g_player[p].ps->vel.z += 512; } - if (onfloorz && sectlotag == 2 && g_player[p].ps->pos.z <= sector[sect].ceilingz /*&& g_player[p].ps->posvel.z == 0*/) + if (onfloorz && sectlotag == 2 && g_player[p].ps->pos.z <= sector[sect].ceilingz /*&& g_player[p].ps->vel.z == 0*/) { k = 1; // if( sprite[j].extra <= 0) break; @@ -3253,8 +3253,8 @@ ACTOR_STATIC void G_MoveTransports(void) g_player[p].ps->jumping_toggle = 1; g_player[p].ps->jumping_counter = 0; - g_player[p].ps->posvel.z = 0; - // g_player[p].ps->posvel.z += 1024; + g_player[p].ps->vel.z = 0; + // g_player[p].ps->vel.z += 1024; } if (k == 1) @@ -3575,7 +3575,7 @@ ACTOR_STATIC void G_MoveActors(void) break; case RAT__STATIC: A_Fall(i); - IFMOVING + if (A_SetSprite(i, CLIPMASK0)) { if ((krand()&255) < 3) A_PlaySound(RATTY,i); s->ang += (krand()&31)-15+(sintable[(t[0]<<8)&2047]>>11); @@ -3767,7 +3767,7 @@ ACTOR_STATIC void G_MoveActors(void) } else if (g_noEnemies == 2) s->cstat = 257; } - IFHIT + if ((j = A_IncurDamage(i)) >= 0) { if (s->extra < 0 && t[0] != -1) { @@ -4005,7 +4005,7 @@ ACTOR_STATIC void G_MoveActors(void) s->picnum = GREENSLIME+2; s->extra = 1; s->pal = 1; - IFHIT + if ((j = A_IncurDamage(i)) >= 0) { if (j == FREEZEBLAST) goto BOLT; for (j=16; j >= 0 ; j--) @@ -4138,7 +4138,7 @@ ACTOR_STATIC void G_MoveActors(void) } } - IFHIT + if ((j = A_IncurDamage(i)) >= 0) { A_PlaySound(SLIM_DYING,i); @@ -4744,7 +4744,7 @@ DETONATEB: } else { - IFHIT + if ((j = A_IncurDamage(i)) >= 0) { for (x=0; x<32; x++) RANDOMSCRAP; @@ -4761,7 +4761,7 @@ DETONATEB: t[1]+=8; if (g_damageCameras) { - IFHIT + if ((j = A_IncurDamage(i)) >= 0) { t[0] = 1; // static s->cstat = (int16_t)32768; @@ -6195,17 +6195,16 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 } else { - t[2] += - G_GetAngleDelta(t[2]+512,getangle(g_player[p].ps->pos.x-s->x,g_player[p].ps->pos.y-s->y))>>2; + t[2] += G_GetAngleDelta(t[2]+512,getangle(g_player[p].ps->pos.x-s->x,g_player[p].ps->pos.y-s->y))>>2; sc->ceilingshade = 0; } - IFHIT + + if ((j = A_IncurDamage(i)) >= 0) { - t[3]++; - if (t[3] == 5) + if (++t[3] == 5) { s->zvel += 1024; - P_DoQuote(7,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_WASTED, g_player[myconnectindex].ps); } } @@ -6312,7 +6311,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 if (GetAnimationGoal(§or[s->sectnum].ceilingz) >= 0) break; default: - activatebysector(s->sectnum,i); + G_ActivateBySector(s->sectnum,i); t[0] = 0; break; } @@ -6821,7 +6820,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 { IFHITSECT { - P_DoQuote(8,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_UNLOCKED,g_player[myconnectindex].ps); l = headspritestat[STAT_EFFECTOR]; while (l >= 0) @@ -8035,6 +8034,48 @@ void G_MoveWorld(void) switch (DynamicTileMap[sprite[i].picnum]) { + case DIPSWITCH__STATIC: + case DIPSWITCH2__STATIC: + case DIPSWITCH3__STATIC: + case PULLSWITCH__STATIC: + case SLOTDOOR__STATIC: + case LIGHTSWITCH__STATIC: + case SPACELIGHTSWITCH__STATIC: + case SPACEDOORSWITCH__STATIC: + case FRANKENSTINESWITCH__STATIC: + case POWERSWITCH1__STATIC: + case LOCKSWITCH1__STATIC: + case POWERSWITCH2__STATIC: + case TECHSWITCH__STATIC: + case ACCESSSWITCH__STATIC: + case ACCESSSWITCH2__STATIC: + { + int32_t x, y; + + if ((s->cstat & 32768) || A_CheckSpriteFlags(i, SPRITE_NOLIGHT) || + !inside(s->x+((sintable[(s->ang+512)&2047])>>9), s->y+((sintable[(s->ang)&2047])>>9), s->sectnum)) + { + if (actor[i].lightptr != NULL) + { + polymer_deletelight(actor[i].lightId); + actor[i].lightId = -1; + actor[i].lightptr = NULL; + } + break; + } + + x = ((sintable[(s->ang+512)&2047])>>7); + y = ((sintable[(s->ang)&2047])>>7); + + s->x += x; + s->y += y; + + G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 768, 255+(48<<8)+(48<<16),PR_LIGHT_PRIO_LOW); + s->x -= x; + s->y -= y; + } + break; + case ATOMICHEALTH__STATIC: G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), LIGHTRAD2 * 3, 128+(128<<8)+(255<<16),PR_LIGHT_PRIO_HIGH_GAME); break; @@ -8043,11 +8084,23 @@ void G_MoveWorld(void) case FIRE2__STATIC: case BURNING__STATIC: case BURNING2__STATIC: - /* - if (Actor[i].floorz - Actor[i].ceilingz < 128) break; - if (s->z > Actor[i].floorz+2048) break; - */ - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), LIGHTRAD2, 255+(95<<8),PR_LIGHT_PRIO_HIGH_GAME); + { + uint32_t color; + /* + if (Actor[i].floorz - Actor[i].ceilingz < 128) break; + if (s->z > Actor[i].floorz+2048) break; + */ + + switch (s->pal) + { + case 1: color = 128+(128<<8)+(255<<16); break; + case 2: color = 255+(48<<8)+(48<<16); break; + case 8: color = 48+(255<<8)+(48<<16); break; + default: color = 255+(95<<8); break; + } + + G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), LIGHTRAD2, color, PR_LIGHT_PRIO_HIGH_GAME); + } break; case OOZFILTER__STATIC: @@ -8139,47 +8192,6 @@ void G_MoveWorld(void) s->y += y; } break; - case DIPSWITCH__STATIC: - case DIPSWITCH2__STATIC: - case DIPSWITCH3__STATIC: - case PULLSWITCH__STATIC: - case SLOTDOOR__STATIC: - case LIGHTSWITCH__STATIC: - case SPACELIGHTSWITCH__STATIC: - case SPACEDOORSWITCH__STATIC: - case FRANKENSTINESWITCH__STATIC: - case POWERSWITCH1__STATIC: - case LOCKSWITCH1__STATIC: - case POWERSWITCH2__STATIC: - case TECHSWITCH__STATIC: - case ACCESSSWITCH__STATIC: - case ACCESSSWITCH2__STATIC: - { - int32_t x, y; - - if ((s->cstat & 32768) || A_CheckSpriteFlags(i, SPRITE_NOLIGHT) || - !inside(s->x+((sintable[(s->ang+512)&2047])>>9), s->y+((sintable[(s->ang)&2047])>>9), s->sectnum)) - { - if (actor[i].lightptr != NULL) - { - polymer_deletelight(actor[i].lightId); - actor[i].lightId = -1; - actor[i].lightptr = NULL; - } - break; - } - - x = ((sintable[(s->ang+512)&2047])>>7); - y = ((sintable[(s->ang)&2047])>>7); - - s->x += x; - s->y += y; - - G_AddGameLight(0, i, ((s->yrepeat*tilesizy[s->picnum])<<1), 768, 255+(48<<8)+(48<<16),PR_LIGHT_PRIO_LOW); - s->x -= x; - s->y -= y; - } - break; } } } diff --git a/polymer-perf/eduke32/source/anim.c b/polymer-perf/eduke32/source/anim.c index a7a73691d..71824e6ad 100644 --- a/polymer-perf/eduke32/source/anim.c +++ b/polymer-perf/eduke32/source/anim.c @@ -202,7 +202,7 @@ void G_PlayAnim(const char *fn,char t) { char *animbuf; int32_t i, length=0, numframes=0; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL int32_t ogltexfiltermode=gltexfiltermode; #endif int32_t handle=-1; @@ -243,7 +243,7 @@ void G_PlayAnim(const char *fn,char t) //setbrightness(ud.brightness>>2,tempbuf,2); P_SetGamePalette(g_player[myconnectindex].ps,ANIMPAL,10); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL gltexfiltermode = 0; gltexapplyprops(); #endif @@ -302,7 +302,7 @@ void G_PlayAnim(const char *fn,char t) } ENDOFANIMLOOP: -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL gltexfiltermode = ogltexfiltermode; gltexapplyprops(); #endif diff --git a/polymer-perf/eduke32/source/astub.c b/polymer-perf/eduke32/source/astub.c index 7c942ebdd..5eeff82d1 100644 --- a/polymer-perf/eduke32/source/astub.c +++ b/polymer-perf/eduke32/source/astub.c @@ -46,6 +46,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "m32script.h" #include "m32def.h" +#include "rev.h" + #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include @@ -54,8 +56,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -#define BUILDDATE " 20100521" - static int32_t floor_over_floor; // static char *startwin_labeltext = "Starting Mapster32..."; @@ -105,12 +105,7 @@ static int32_t curcorruptthing=-1; int32_t corruptlevel=0, numcorruptthings=0, corruptthings[MAXCORRUPTTHINGS]; -static uint32_t templenrepquot; -static void fixxrepeat(int16_t i, uint32_t lenrepquot) -{ - if (lenrepquot != 0) - wall[i].xrepeat = clamp(divscale12(wallength(i), lenrepquot), 1, 255); -} +static uint32_t templenrepquot=1; //////////////////// Key stuff //////////////////// @@ -167,9 +162,6 @@ static const char *Typestr_wss[] = { "Wall", "Sector", "Sector", "Sprite", "Wall #define AIMED_SELOVR_PICNUM SFBASE_CF(picnum, &AIMED_SELOVR_WALL(picnum)) -#define BTAG_MAX 65535 -#define BZ_MAX 8388608 - static const char *ONOFF_[] = {"OFF","ON"}; #define ONOFF(b) (ONOFF_[!!(b)]) @@ -268,6 +260,8 @@ mapundo_t *mapstate = NULL; int32_t map_revision = 1; +#define QADDNSZ 400 + void create_map_snapshot(void) { int32_t j; @@ -288,29 +282,30 @@ void create_map_snapshot(void) { if (mapstate->next != NULL) { - mapundo_t *next = mapstate->next; - next->prev = NULL; + mapundo_t *cur = mapstate->next; + cur->prev = NULL; - while (next->next) - next = next->next; + while (cur->next) + cur = cur->next; do { - if (next->sectors && (next->prev == NULL || (next->sectcrc != next->prev->sectcrc))) - Bfree(next->sectors); - if (next->walls && (next->prev == NULL || (next->wallcrc != next->prev->wallcrc))) - Bfree(next->walls); - if (next->sprites && (next->prev == NULL || (next->spritecrc != next->prev->spritecrc))) - Bfree(next->sprites); - if (!next->prev) + if (cur->sectors && (cur->prev == NULL || (cur->sectcrc != cur->prev->sectcrc))) + Bfree(cur->sectors); + if (cur->walls && (cur->prev == NULL || (cur->wallcrc != cur->prev->wallcrc))) + Bfree(cur->walls); + if (cur->sprites && (cur->prev == NULL || (cur->spritecrc != cur->prev->spritecrc))) + Bfree(cur->sprites); + if (!cur->prev) { - Bfree(next); + Bfree(cur); break; } - next = next->prev; - Bfree(next->next); + + cur = cur->prev; + Bfree(cur->next); } - while (next); + while (cur); } mapstate->next = (mapundo_t *)Bcalloc(1, sizeof(mapundo_t)); @@ -321,13 +316,7 @@ void create_map_snapshot(void) } fixspritesectors(); - - numsprites = 0; - for (j=MAXSPRITES-1; j>=0; j--) - { - if (sprite[j].statnum != MAXSTATUS) - numsprites++; - } + updatenumsprites(); mapstate->numsectors = numsectors; mapstate->numwalls = numwalls; @@ -347,7 +336,7 @@ void create_map_snapshot(void) } else { - mapstate->sectors = (sectortype *)Bcalloc(1, sizeof(sectortype) * numsectors); + mapstate->sectors = (sectortype *)Bcalloc(1, sizeof(sectortype) * numsectors + QADDNSZ); mapstate->sectsiz = j = qlz_compress(§or[0], (char *)&mapstate->sectors[0], sizeof(sectortype) * numsectors, state_compress); mapstate->sectors = (sectortype *)Brealloc(mapstate->sectors, j); @@ -368,7 +357,7 @@ void create_map_snapshot(void) } else { - mapstate->walls = (walltype *)Bcalloc(1, sizeof(walltype) * numwalls); + mapstate->walls = (walltype *)Bcalloc(1, sizeof(walltype) * numwalls + QADDNSZ); mapstate->wallsiz = j = qlz_compress(&wall[0], (char *)&mapstate->walls[0], sizeof(walltype) * numwalls, state_compress); mapstate->walls = (walltype *)Brealloc(mapstate->walls, j); @@ -390,18 +379,19 @@ void create_map_snapshot(void) else { int32_t i = 0; - spritetype *tspri = (spritetype *)Bcalloc(1, sizeof(spritetype) * numsprites), + spritetype *tspri = (spritetype *)Bcalloc(1, sizeof(spritetype) * numsprites + 1), *spri = &tspri[0]; - mapstate->sprites = (spritetype *)Bcalloc(1, sizeof(spritetype) * numsprites); + mapstate->sprites = (spritetype *)Bcalloc(1, sizeof(spritetype) * numsprites + QADDNSZ); for (j=0; jspritesiz = j = qlz_compress(&tspri[0], (char *)&mapstate->sprites[0], sizeof(spritetype) * numsprites, state_compress); mapstate->sprites = (spritetype *)Brealloc(mapstate->sprites, j); @@ -410,6 +400,8 @@ void create_map_snapshot(void) } } } + + CheckMapCorruption(6, 0); } void map_undoredo_free(void) @@ -471,6 +463,7 @@ int32_t map_undoredo(int32_t dir) Bmemset(show2dsector, 0, sizeof(show2dsector)); Bmemset(show2dsprite, 0, sizeof(show2dsprite)); Bmemset(show2dwall, 0, sizeof(show2dwall)); + Bmemset(hlsectorbitmap, 0, sizeof(hlsectorbitmap)); if (mapstate->numsectors) { @@ -495,6 +488,9 @@ int32_t map_undoredo(int32_t dir) if (qsetmode == 200 && rendmode == 4) polymer_loadboard(); #endif + + CheckMapCorruption(4, 0); + return 0; } @@ -591,6 +587,11 @@ static int32_t getfilenames(const char *path, const char *kind) return(0); } +const char *ExtGetVer(void) +{ + return s_buildRev; +} + void ExtLoadMap(const char *mapname) { int32_t i; @@ -852,8 +853,8 @@ const char *SectorEffectorTagText(int32_t lotag) "CONVAYER BELT", "ENGINE", // 25 "(UNKNOWN)", - "LIGHTNING (H= TILE#4890)", "CAMERA FOR PLAYBACK", + "LIGHTNING (H= TILE#4890)", "FLOAT", "2 WAY TRAIN (ST=31)", // 30 "FLOOR RISE", @@ -2506,14 +2507,14 @@ static void ReadPaletteTable() // initprintf("success.\n"); }// end ReadPaletteTable -static void ReadGamePalette() +static void ReadGamePalette(void) { int32_t fp; if ((fp=kopen4load("palette.dat",0)) == -1) if ((fp=kopen4load("palette.dat",1)) == -1) { initprintf("!!! PALETTE.DAT NOT FOUND !!!\n"); - Bstrcpy(tempbuf, "Mapster32"VERSION BUILDDATE); + Bsprintf(tempbuf, "Mapster32 %s %s", VERSION, s_buildRev); wm_msgbox(tempbuf,"palette.dat not found"); exit(0); } @@ -3212,7 +3213,6 @@ static int32_t m32gettile(int32_t idInitialTile) keystatus[KEYSC_ENTER] = 0; return idSelectedTile; - } // Dir = 0 (zoom out) or 1 (zoom in) @@ -3624,13 +3624,13 @@ static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, i y1=max(y1, 0); y2=min(y2, ydim-1); - // box - { + // box int32_t xx[] = {x1, x1, x2, x2, x1}; int32_t yy[] = {y1, y2, y2, y1, y1}; plotlines2d(xx, yy, 5, iTile==iSelected ? whitecol : markedcol); } + // cross if (marked) { @@ -3672,10 +3672,19 @@ static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, i Bsprintf(szT,"%dx%d",tilesizx[idTile],tilesizy[idTile]); printext256(xdim>>2,ydim-10,whitecol,-1,szT,0); - // EditArt animation flags. - Bsprintf(szT,"%d, %d",(picanm[idTile]>>8)&0xFF,(picanm[idTile]>>16)&0xFF); + // EditArt offset flags. + Bsprintf(szT,"%d, %d", (int8_t)((picanm[idTile]>>8)&0xFF), (int8_t)((picanm[idTile]>>16)&0xFF)); printext256((xdim>>2)+100,ydim-10,whitecol,-1,szT,0); + // EditArt animation flags. + if (picanm[idTile]&0xc0) + { + static const char *anmtype[] = {"", "Osc", "Fwd", "Bck"}; + + Bsprintf(szT,"%s %d", anmtype[(picanm[idTile]&0xc0)>>6], picanm[idTile]&0x3f); + printext256((xdim>>2)+100+14*8,ydim-10,whitecol,-1,szT,0); + } + if (showmsg) TMPERRMSG_SHOW(0); @@ -3698,11 +3707,12 @@ static int32_t spriteonceilingz(int32_t searchwall) // int32_t z=sprite[searchwall].z; int32_t z = getceilzofslope(searchsector,sprite[searchwall].x,sprite[searchwall].y); + int32_t tmphei = spriteheight(searchwall, NULL); if (sprite[searchwall].cstat&128) - z -= ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<1); + z -= tmphei>>1; if ((sprite[searchwall].cstat&48) != 32) - z += ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<2); + z += tmphei; return z; } @@ -3713,7 +3723,7 @@ static int32_t spriteongroundz(int32_t searchwall) int32_t z = getflorzofslope(searchsector,sprite[searchwall].x,sprite[searchwall].y); if (sprite[searchwall].cstat&128) - z -= ((tilesizy[sprite[searchwall].picnum]*sprite[searchwall].yrepeat)<<1); + z -= spriteheight(searchwall, NULL)>>1; return z; } @@ -3817,9 +3827,7 @@ static void getnumberptr256(const char *namestart, void *num, int32_t bytes, int quitevent = 0; drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); -#ifdef SUPERBUILD ExtAnalyzeSprites(); -#endif drawmasks(); #ifdef POLYMER if (rendmode == 4 && searchit == 2) @@ -3918,37 +3926,6 @@ static void getnumberptr256(const char *namestart, void *num, int32_t bytes, int } } -static void DoSpriteOrnament(int32_t i) -{ - int32_t j, hitw; - hitdata_t hitinfo; - - hitscan((const vec3_t *)&sprite[i],sprite[i].sectnum, - sintable[(sprite[i].ang+1536)&2047], - sintable[(sprite[i].ang+1024)&2047], - 0, - &hitinfo,CLIPMASK1); - - sprite[i].x = hitinfo.pos.x; - sprite[i].y = hitinfo.pos.y; - sprite[i].z = hitinfo.pos.z; - changespritesect(i,hitinfo.hitsect); - - hitw = hitinfo.hitwall; - - if (hitw >= 0) - sprite[i].ang = (getangle(POINT2(hitw).x-wall[hitw].x, - POINT2(hitw).y-wall[hitw].y)+512)&2047; - - //Make sure sprite's in right sector - if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) - { - j = wall[hitw].point2; - sprite[i].x -= ksgn(wall[j].y-wall[hitw].y); - sprite[i].y += ksgn(wall[j].x-wall[hitw].x); - } -} - #if 0 int64_t ldistsqr(spritetype *s1,spritetype *s2) { @@ -4074,9 +4051,7 @@ ENDFOR1: sprite[linebegspr].pal -= (sprite[linebegspr].pal>0); drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); -#ifdef SUPERBUILD ExtAnalyzeSprites(); -#endif drawmasks(); #ifdef POLYMER if (rendmode == 4 && searchit == 2) @@ -4308,6 +4283,7 @@ static void mouseaction_movesprites(int32_t *sumxvect, int32_t *sumyvect, int32_ xvect = daxvect; yvect = dayvect; + // test run for (ii=0; ii=MAXTILES) + break; + if (names[sprite[searchwall].picnum][0]) { if (sprite[searchwall].picnum==SECTOREFFECTOR) @@ -4541,6 +4522,9 @@ static void Keys3d(void) if (AIMING_AT_MASKWALL && wall[searchwall].nextwall >= 0) NEXTWALL(searchwall).overpicnum = tempint; + if (AIMING_AT_SPRITE) + correct_sprite_yoffset(searchwall); + if (oldtile != tempint) asksave = 1; } @@ -4690,7 +4674,7 @@ static void Keys3d(void) if (AIMING_AT_WALL_OR_MASK && PRESSED_KEYSC(PERIOD)) { - AutoAlignWalls((int32_t)searchwall, 0); + AutoAlignWalls(searchwall, 0); message("Wall %d autoalign", searchwall); } @@ -4725,7 +4709,7 @@ static void Keys3d(void) sector[searchsector].ceilingheinum = 0; } getnumberptr256("Sector ceiling slope: ", §or[searchsector].ceilingheinum, - sizeof(sector[0].ceilingheinum), 65536, 1, NULL); + sizeof(sector[0].ceilingheinum), 32767, 1, NULL); break; case SEARCH_FLOOR: getnumberptr256("Sector floorz: ", §or[searchsector].floorz, @@ -4736,7 +4720,7 @@ static void Keys3d(void) sector[searchsector].floorstat |= 2; } getnumberptr256("Sector floor slope: ", §or[searchsector].floorheinum, - sizeof(sector[0].floorheinum), 65536, 1, NULL); + sizeof(sector[0].floorheinum), 32767, 1, NULL); break; case SEARCH_SPRITE: @@ -4914,11 +4898,19 @@ static void Keys3d(void) smooshyalign = keystatus[KEYSC_gKP5]; repeatpanalign = eitherSHIFT || eitherALT || (bstatus&2); - if (mlook == 2) - mlook = 0; + { + static int32_t omlook; - if (!unrealedlook && (bstatus&4)) - mlook = 2; + if (mlook == 2) + { + mlook = omlook; + } + else if (!unrealedlook && (bstatus&4)) + { + omlook = mlook; + mlook = 2; + } + } // PK: no btn: wheel changes shade if ((bstatus&(16|32) && !(bstatus&(1|2|4))) || keystatus[KEYSC_gMINUS] || keystatus[KEYSC_gPLUS]) @@ -5053,6 +5045,9 @@ static void Keys3d(void) j = 0; } + if (AIMING_AT_SPRITE) + correct_sprite_yoffset(searchwall); + asksave = 1; } keystatus[KEYSC_DASH] = keystatus[KEYSC_EQUAL] = 0; @@ -5212,22 +5207,22 @@ static void Keys3d(void) int16_t sect = k ? highlightsector[0] : ((AIMING_AT_WALL && wall[searchwall].nextsector>=0 && (eitherALT && !(bstatus&1))) ? wall[searchwall].nextsector : searchsector); + int32_t tmphei; for (j=0; j<(k?k:1); j++, sect=highlightsector[j]) { - i = headspritesect[sect]; - while (i != -1) + for (i=headspritesect[sect]; i!=-1; i=nextspritesect[i]) { + tmphei = spriteheight(i, NULL); + tempint = getceilzofslope(sect, sprite[i].x, sprite[i].y); - tempint += (tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<2; + tempint += tmphei; if (sprite[i].cstat&128) - tempint += (tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1; + tempint += tmphei>>1; if (sprite[i].z == tempint) sprite[i].z += tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128 - - i = nextspritesect[i]; } sector[sect].ceilingz += tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128 @@ -5240,18 +5235,15 @@ static void Keys3d(void) for (j=0; j<(k?k:1); j++, sect=highlightsector[j]) { - i = headspritesect[sect]; - while (i != -1) + for (i=headspritesect[sect]; i!=-1; i=nextspritesect[i]) { tempint = getflorzofslope(sect,sprite[i].x,sprite[i].y); if (sprite[i].cstat&128) - tempint += ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); + tempint += spriteheight(i, NULL)>>1; if (sprite[i].z == tempint) sprite[i].z += tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128 - - i = nextspritesect[i]; } sector[sect].floorz += tsign * (updownunits << (eitherCTRL<<1)); // JBF 20031128 @@ -5581,7 +5573,7 @@ static void Keys3d(void) if (ASSERT_AIMING) { - message("%ss with picnum %d have shade of %d", Typestr[searchstat], temppicnum, tempshade); + message("%ss with picnum %d now have shade of %d", Typestr[searchstat], temppicnum, tempshade); asksave = 1; } } @@ -5629,7 +5621,8 @@ static void Keys3d(void) int16_t ohitag = AIMED(hitag); Bsprintf(tempbuf, "%s hitag: ", Typestr_wss[searchstat]); AIMED(hitag) = getnumber256(tempbuf, ohitag, BTAG_MAX,0); - asksave |= (AIMED(hitag) != ohitag); + if (AIMED(hitag) != ohitag) + asksave = 1; } } @@ -5640,7 +5633,8 @@ static void Keys3d(void) int8_t oshade = AIMED_CF_SEL(shade); Bsprintf(tempbuf, "%s shade: ", Typestr[searchstat]); getnumberptr256(tempbuf, &AIMED_CF_SEL(shade), sizeof(int8_t), 128, 1, NULL); - asksave |= (AIMED_CF_SEL(shade) != oshade); + if (AIMED_CF_SEL(shade) != oshade) + asksave = 1; } } @@ -5694,11 +5688,15 @@ static void Keys3d(void) { if (ASSERT_AIMING) { - int16_t opicnum = AIMED_CF_SEL(picnum); + int16_t opicnum = AIMED_CF_SEL(picnum), aimspr=AIMING_AT_SPRITE; static const char *Typestr_tmp[5] = { "Wall", "Sector ceiling", "Sector floor", "Sprite", "Masked wall" }; Bsprintf(tempbuf, "%s picnum: ", Typestr_tmp[searchstat]); getnumberptr256(tempbuf, &AIMED_CF_SEL(picnum), sizeof(int16_t), MAXTILES-1, 0, NULL); - asksave |= (opicnum != AIMED_CF_SEL(picnum)); + if (opicnum != AIMED_CF_SEL(picnum)) + asksave = 1; + + if (aimspr) + correct_sprite_yoffset(searchwall); } } @@ -5798,6 +5796,9 @@ static void Keys3d(void) { AIMED_SELOVR_PICNUM = temppicnum; message("Pasted picnum only"); + + if (AIMING_AT_SPRITE) + correct_sprite_yoffset(searchwall); } i = 512; @@ -5964,7 +5965,7 @@ static void Keys3d(void) mouseay=0; } - if ((bstatus&1) && searchstat != SEARCH_CEILING && searchstat != SEARCH_FLOOR) + if ((bstatus&1) && !AIMING_AT_CEILING_OR_FLOOR) { if (eitherSHIFT) { @@ -5973,7 +5974,7 @@ static void Keys3d(void) { mouseaction = 1; mouseax += mousex; - updownunits = klabs((int32_t)(mouseax/2.)); + updownunits = klabs(mouseax/2); if (updownunits) mouseax=0; } @@ -6016,10 +6017,10 @@ static void Keys3d(void) if (mouseaction) { - i=wall[w].cstat; - i=((i>>3)&1)+((i>>7)&2); + i = wall[w].cstat; + i &= (8|256); - if (i==1||i==3) + if (i==8 || i==256) changedir*=-1; if (eitherCTRL) @@ -6443,6 +6444,8 @@ static void Keys3d(void) sprite[searchwall].yvel = tempyvel; sprite[searchwall].zvel = tempzvel; } + else + correct_sprite_yoffset(searchwall); } message("Pasted clipboard"); asksave = 1; @@ -6475,7 +6478,10 @@ static void Keys3d(void) for (i=0; i= 2 && totalclock >= 120*6) @@ -6825,7 +6831,7 @@ static void Keys2d(void) else { for (i=0; i0) || (tsign>0 && curwallnum>grid); } + if (autogrid) { grid = min(zoom+512, 65536); @@ -7176,8 +7181,7 @@ static void Keys2d(void) sprite[i].ang &= 2047; printmessage16("Sprite %d updated", i); } - - else if (pointhighlight >= 0 /*<= 16383*/) + else if (pointhighlight >= 0) { i = linehighlight; j = wall[i].x; @@ -7339,7 +7343,7 @@ void ExtPreSaveMap(void) startwall = sector[i].wallptr; endwall = startwall + sector[i].wallnum; for (j=startwall; j\t\tOverride NAMES.H\n" #if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2) "-setup\t\tDisplays the configuration dialog\n" #endif @@ -7360,7 +7365,8 @@ static void G_ShowParameterHelp(void) #endif "\n-?, -help, --help\tDisplay this help message and exit" ; - wm_msgbox("Mapster32"VERSION BUILDDATE,"%s",s); + Bsprintf(tempbuf, "Mapster32 %s %s", VERSION, s_buildRev); + wm_msgbox(tempbuf, "%s", s); } static void AddGamePath(const char *buffer) @@ -7417,7 +7423,10 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) { lengths = Bmalloc(argc*sizeof(int32_t)); for (j=1; j i+1) { -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL extern char TEXCACHEFILE[BMAX_PATH]; Bsprintf(tempbuf,"%s/%s",argv[i+1],TEXCACHEFILE); @@ -7500,6 +7509,12 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) i++; continue; } + if (!Bstrcasecmp(c+1,"namesfile")) + { + g_namesFileName = argv[i+1]; + i++; + continue; + } if (!Bstrcasecmp(c+1,"ww2gi")) { Bstrcpy(g_grpNamePtr, "ww2gi.grp"); @@ -7646,8 +7661,9 @@ int32_t ExtPreInit(int32_t argc,const char **argv) #endif OSD_SetLogFile("mapster32.log"); - OSD_SetVersion("Mapster32"VERSION,0,2); - initprintf("Mapster32"VERSION BUILDDATE"\n"); + OSD_SetVersion("Mapster32" " " VERSION,0,2); + initprintf("Mapster32 %s %s\n", VERSION, s_buildRev); + initprintf("Compiled %s\n", __DATE__" "__TIME__); // initprintf("Copyright (c) 2008 EDuke32 team\n"); G_CheckCommandLine(argc,argv); @@ -7881,7 +7897,7 @@ static int32_t osdcmd_vars_pk(const osdfuncparm_t *parm) } else if (tryfix) { - uint64_t whicherrs = parm->numparms==1 ? ULONG_LONG_MAX : 0; + uint64_t whicherrs = parm->numparms==1 ? 0xffffffffffffffffull : 0; if (whicherrs==0) { @@ -7897,7 +7913,7 @@ static int32_t osdcmd_vars_pk(const osdfuncparm_t *parm) m = (int32_t)Bstrtol(endptr+1, NULL, 10); if (n>=1 && n<=m && m<=MAXCORRUPTTHINGS) { - uint64_t mask = ULONG_LONG_MAX; + uint64_t mask = 0xffffffffffffffffull; m = m-n+1; mask >>= (MAXCORRUPTTHINGS-m); mask <<= (n-1); @@ -7938,7 +7954,7 @@ static int32_t osdcmd_vars_pk(const osdfuncparm_t *parm) return OSDCMD_OK; } -#ifdef POLYMOST +#ifdef USE_OPENGL static int32_t osdcmd_tint(const osdfuncparm_t *parm) { int32_t i; @@ -8114,7 +8130,7 @@ static int32_t osdcmd_do(const osdfuncparm_t *parm) return OSDCMD_OK; OUTOFMEM: - OSD_Printf("OUT OF MEMORY!\n"); + message("OUT OF MEMORY!\n"); return OSDCMD_OK; } @@ -8213,7 +8229,7 @@ static int32_t registerosdcommands(void) OSD_RegisterFunction("show_heightindicators", "show_heightindicators {0, 1 or 2}: sets display of height indicators in 2D mode", osdcmd_vars_pk); OSD_RegisterFunction("show_ambiencesounds", "show_ambiencesounds {0, 1 or 2}>: sets display of MUSICANDSFX circles in 2D mode", osdcmd_vars_pk); OSD_RegisterFunction("corruptcheck", "corruptcheck {|now|tryfix}: sets auto corruption check interval if given, otherwise as indicated", osdcmd_vars_pk); -#ifdef POLYMOST +#ifdef USE_OPENGL OSD_RegisterFunction("tint", "tint : queries or sets hightile tinting", osdcmd_tint); #endif @@ -8234,6 +8250,7 @@ static int32_t registerosdcommands(void) #define DUKEOSD #ifdef DUKEOSD +#if 0 void GAME_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, int32_t pal) { int32_t ac; @@ -8264,12 +8281,14 @@ void GAME_drawosdstr(int32_t x, int32_t y, char *ch, int32_t len, int32_t shade, else x += tilesizx[ac]; } } +#endif static int32_t GetTime(void) { return totalclock; } +#if 0 void GAME_drawosdcursor(int32_t x, int32_t y, int32_t type, int32_t lastkeypress) { int32_t ac; @@ -8290,6 +8309,7 @@ int32_t GAME_getrowheight(int32_t w) { return w>>3; } +#endif //#define BGTILE 311 //#define BGTILE 1156 @@ -8304,7 +8324,7 @@ void GAME_clearbackground(int32_t numcols, int32_t numrows) { UNREFERENCED_PARAMETER(numcols); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL // if (getrendermode() < 3) bits = BITS; // else if (rendmode>=3 && qsetmode==200) @@ -8332,7 +8352,8 @@ void GAME_clearbackground(int32_t numcols, int32_t numrows) ysiz = tilesizx[BORDTILE]; for (x=0; x<=tx2; x++) - rotatesprite(x*xsiz<<16,(daydim+ysiz+1)<<16,65536L,1536,BORDTILE,SHADE-12,PALETTE,BITS,0,0,xdim,daydim+ysiz+1); + rotatesprite(x*xsiz<<16,(daydim+ysiz+1)<<16,65536L,1536, + BORDTILE,SHADE-12,PALETTE,BITS,0,0,xdim,daydim+ysiz+1); return; } @@ -8353,7 +8374,7 @@ static void m32_osdsetfunctions() */ 0,0,0,0,0, GAME_clearbackground, - (int32_t( *)(void))GetTime, + /*(int32_t( *)(void))*/GetTime, NULL ); } @@ -9186,13 +9207,14 @@ int32_t ExtInit(void) bpp = 32; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL glusetexcache = -1; if (Bstrcmp(setupfilename, "mapster32.cfg")) initprintf("Using config file '%s'.\n",setupfilename); - if (loadsetup(setupfilename) < 0) initprintf("Configuration file not found, using defaults.\n"), rv = 1; + if (loadsetup(setupfilename) < 0) + initprintf("Configuration file not found, using defaults.\n"), rv = 1; if (glusetexcache == -1) { @@ -9210,7 +9232,7 @@ int32_t ExtInit(void) } #endif - Bmemcpy((void *)buildkeys,(void *)keys,NUMBUILDKEYS); //Trick to make build use setup.dat keys + Bmemcpy(buildkeys, default_buildkeys, NUMBUILDKEYS); //Trick to make build use setup.dat keys if (initengine()) { @@ -9223,7 +9245,6 @@ int32_t ExtInit(void) kensplayerheight = 40; //32 zmode = 2; zlock = kensplayerheight<<8; - defaultspritecstat = 0; ReadGamePalette(); // InitWater(); @@ -9233,7 +9254,7 @@ int32_t ExtInit(void) getmessageleng = 0; getmessagetimeoff = 0; - Bstrcpy(apptitle, "Mapster32"VERSION BUILDDATE); + Bsprintf(apptitle, "Mapster32 %s %s", VERSION, s_buildRev); autosavetimer = totalclock+120*autosave; #if defined(DUKEOSD) @@ -9781,7 +9802,7 @@ void ExtAnalyzeSprites(void) } // else tspr->cstat&=32767; -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL if (!usemodels || md_tilehasmodel(tspr->picnum,tspr->pal) < 0) #endif { @@ -10039,17 +10060,28 @@ void ExtCheckKeys(void) } } - if (asksave == 1 && (bstatus + lastbstatus) == 0 && mapstate) - { - // message("Saved undo rev %d",map_revision); - create_map_snapshot(); + if (asksave == 1) asksave++; + else if (asksave == 2 && (bstatus + lastbstatus) == 0 && mapstate) + { + int32_t i; + // check keys so that e.g. bulk deletions won't produce + // as much revisions as deleted sprites + for (i=sizeof(keystatus)/sizeof(keystatus[0])-1; i>=0; i--) + if (keystatus[i]) + break; + if (i==-1) + { + create_map_snapshot(); + asksave++; + } } - else if (asksave == 2) asksave++; + else if (asksave == 3) + asksave++; if (totalclock > autosavetimer && autosave) { - if (asksave == 3) + if (asksave == 4) { if (CheckMapCorruption(6, 0)>=4) { @@ -10062,7 +10094,7 @@ void ExtCheckKeys(void) message("Board autosaved to AUTOSAVE.MAP"); } - asksave = 4; + asksave++; } autosavetimer = totalclock+120*autosave; } @@ -10288,6 +10320,14 @@ int32_t CheckMapCorruption(int32_t printfromlev, uint64_t tryfixing) } } } +#if 0 + // this one usually appears together with the "already referenced" corruption + else if (wall[nw].nextsector != i || wall[nw].nextwall != j) + { + CORRUPTCHK_PRINT(4, CORRUPT_WALL|nw, "WALL %d nextwall's backreferences inconsistent. Expected nw=%d, ns=%d; got nw=%d, ns=%d", + nw, i, j, wall[nw].nextsector, wall[nw].nextwall); + } +#endif } } @@ -10569,7 +10609,7 @@ static void EditSectorData(int16_t sectnum) break; case 5: handlemed(0, "Ceiling heinum", "Ceiling Heinum", §or[sectnum].ceilingheinum, - sizeof(sector[sectnum].ceilingheinum), 65536L, 1); + sizeof(sector[sectnum].ceilingheinum), 32767, 1); break; case 6: handlemed(0, "Palookup number", "Ceiling Palookup Number", §or[sectnum].ceilingpal, @@ -10583,7 +10623,7 @@ static void EditSectorData(int16_t sectnum) { case 0: handlemed(1, "Flags (hex)", "Floor Flags", §or[sectnum].floorstat, - sizeof(sector[sectnum].floorstat), 65536, 0); + sizeof(sector[sectnum].floorstat), 65535, 0); break; case 1: @@ -10613,7 +10653,7 @@ static void EditSectorData(int16_t sectnum) break; case 5: handlemed(0, "Floor heinum", "Floor Heinum", §or[sectnum].floorheinum, - sizeof(sector[sectnum].floorheinum), 65536, 1); + sizeof(sector[sectnum].floorheinum), 32767, 1); break; case 6: handlemed(0, "Palookup number", "Floor Palookup Number", §or[sectnum].floorpal, @@ -10661,7 +10701,7 @@ static void EditWallData(int16_t wallnum) { case 0: handlemed(1, "Flags (hex)", "Flags", &wall[wallnum].cstat, - sizeof(wall[wallnum].cstat), 65536L, 0); + sizeof(wall[wallnum].cstat), 65535, 0); break; case 1: handlemed(0, "Shade", "Shade", &wall[wallnum].shade, @@ -10908,15 +10948,15 @@ static void EditSpriteData(int16_t spritenum) break; case 1: handlemed(0, "X-Velocity", "X-Velocity", &sprite[spritenum].xvel, - sizeof(sprite[spritenum].xvel), 65536, 1); + sizeof(sprite[spritenum].xvel), 65535, 1); break; case 2: handlemed(0, "Y-Velocity", "Y-Velocity", &sprite[spritenum].yvel, - sizeof(sprite[spritenum].yvel), 65536, 1); + sizeof(sprite[spritenum].yvel), 65535, 1); break; case 3: handlemed(0, "Z-Velocity", "Z-Velocity", &sprite[spritenum].zvel, - sizeof(sprite[spritenum].zvel), 65536, 1); + sizeof(sprite[spritenum].zvel), 65535, 1); break; case 4: handlemed(0, "Owner", "Owner", &sprite[spritenum].owner, @@ -10973,10 +11013,10 @@ static void GenericSpriteSearch() static int32_t maxval[7][3] = { - { BXY_MAX , 65536 , 2048 }, - { BXY_MAX , 128 , 65536 }, - { BZ_MAX , MAXPALOOKUPS-1, 65536 }, - { MAXSECTORS-1, 128 , 65536 }, + { BXY_MAX , 65535 , 2048 }, + { BXY_MAX , 128 , 65535 }, + { BZ_MAX , MAXPALOOKUPS-1, 65535 }, + { MAXSECTORS-1, 128 , 65535 }, { MAXSTATUS-1 , 128 , MAXSPRITES-1 }, { BTAG_MAX , MAXTILES-1 , 256 }, { BTAG_MAX , 0 , BTAG_MAX } diff --git a/polymer-perf/eduke32/source/config.c b/polymer-perf/eduke32/source/config.c index e8836ed0c..7f3127b31 100644 --- a/polymer-perf/eduke32/source/config.c +++ b/polymer-perf/eduke32/source/config.c @@ -187,7 +187,7 @@ void CONFIG_SetDefaults(void) ud.config.ScreenWidth = 1024; ud.config.ScreenHeight = 768; ud.config.ScreenMode = 0; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL ud.config.ScreenBPP = 32; #else ud.config.ScreenBPP = 8; @@ -832,7 +832,7 @@ void CONFIG_WriteBinds(void) // save binds and aliases to _settings.cfg Bfree(ptr); } -void CONFIG_WriteSetup(void) +void CONFIG_WriteSetup(uint32_t flags) { int32_t dummy; char tempbuf[1024]; @@ -844,12 +844,6 @@ void CONFIG_WriteSetup(void) SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Executions",++ud.executions,FALSE,FALSE); - for (dummy=0; dummy<10; dummy++) - { - Bsprintf(buf,"WeaponChoice%d",dummy); - SCRIPT_PutNumber(ud.config.scripthandle, "Misc",buf,g_player[myconnectindex].wchoice[dummy],FALSE,FALSE); - } - SCRIPT_PutNumber(ud.config.scripthandle, "Setup","ConfigVersion",BYTEVERSION_JF,FALSE,FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ForceSetup",ud.config.ForceSetup,FALSE,FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "NoAutoLoad",ud.config.NoAutoLoad,FALSE,FALSE); @@ -858,23 +852,44 @@ void CONFIG_WriteSetup(void) SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Polymer",glrendmode == 4 && bpp > 8,FALSE,FALSE); #endif - if (!NAM) - { - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Out",ud.lockout,FALSE,FALSE); - SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "Password",ud.pwlockout); - } - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP",ud.config.ScreenBPP,FALSE,FALSE); // JBF 20040523 SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight",ud.config.ScreenHeight,FALSE,FALSE); // JBF 20031206 SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode",ud.config.ScreenMode,FALSE,FALSE); // JBF 20031206 SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth",ud.config.ScreenWidth,FALSE,FALSE); // JBF 20031206 + + SCRIPT_PutString(ud.config.scripthandle, "Setup","SelectedGRP",&g_grpNamePtr[0]); + + if (g_noSetup == 0) + SCRIPT_PutString(ud.config.scripthandle, "Setup","ModDir",&g_modDir[0]); + + // exit early after only updating the values that can be changed from the startup window + if (flags & 1) + { + SCRIPT_Save(ud.config.scripthandle, setupfilename); + SCRIPT_Free(ud.config.scripthandle); + OSD_Printf("Updated %s\n",setupfilename); + + return; + } + #ifdef RENDERTYPEWIN SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", windowpos, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", windowx, FALSE, FALSE); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", windowy, FALSE, FALSE); #endif + for (dummy=0; dummy<10; dummy++) + { + Bsprintf(buf,"WeaponChoice%d",dummy); + SCRIPT_PutNumber(ud.config.scripthandle, "Misc",buf,g_player[myconnectindex].wchoice[dummy],FALSE,FALSE); + } + + if (!NAM) + { + SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Out",ud.lockout,FALSE,FALSE); + SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "Password",ud.pwlockout); + } #ifdef _WIN32 SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", ud.config.CheckForUpdates, FALSE, FALSE); @@ -984,13 +999,6 @@ void CONFIG_WriteSetup(void) SCRIPT_PutString(ud.config.scripthandle, "Comm Setup","PlayerName",&szPlayerName[0]); SCRIPT_PutString(ud.config.scripthandle, "Comm Setup","RTSName",&ud.rtsname[0]); - SCRIPT_PutString(ud.config.scripthandle, "Setup","SelectedGRP",&g_grpNamePtr[0]); - -// #ifdef _WIN32 - if (g_noSetup == 0) - SCRIPT_PutString(ud.config.scripthandle, "Setup","ModDir",&g_modDir[0]); -// #endif - { char commmacro[] = "CommbatMacro# "; diff --git a/polymer-perf/eduke32/source/config.h b/polymer-perf/eduke32/source/config.h index 60374e425..f993e9261 100644 --- a/polymer-perf/eduke32/source/config.h +++ b/polymer-perf/eduke32/source/config.h @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int32_t CONFIG_ReadSetup( void ); void CONFIG_GetSetupFilename( void ); -void CONFIG_WriteSetup( void ); +void CONFIG_WriteSetup(uint32_t flags); void CONFIG_SetupMouse( void ); void CONFIG_SetupJoystick( void ); void CONFIG_SetDefaultKeys(int32_t type); diff --git a/polymer-perf/eduke32/source/demo.c b/polymer-perf/eduke32/source/demo.c index 01328108e..7a8d9f5b0 100644 --- a/polymer-perf/eduke32/source/demo.c +++ b/polymer-perf/eduke32/source/demo.c @@ -138,8 +138,8 @@ void G_OpenDemoWrite(void) if ((g_player[myconnectindex].ps->gm&MODE_GAME) && g_player[myconnectindex].ps->dead_flag) { - Bstrcpy(ScriptQuotes[122], "CANNOT START DEMO RECORDING WHEN DEAD!"); - P_DoQuote(122, g_player[myconnectindex].ps); + Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "CANNOT START DEMO RECORDING WHEN DEAD!"); + P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps); ud.recstat = ud.m_recstat = 0; return; } @@ -156,30 +156,35 @@ void G_OpenDemoWrite(void) OSD_Printf("contain a RESIZEARRAY command, you can force recording with the\n"); OSD_Printf("`demorec_force' cvar. Alternatively, you can disable diff recording\n"); OSD_Printf("with the `demorec_diffs' cvar.\n\n"); - Bstrcpy(ScriptQuotes[122], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS."); - P_DoQuote(122, g_player[myconnectindex].ps); + Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS."); + P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps); ud.recstat = ud.m_recstat = 0; return; } } - while (1) + do { if (demonum == 10000) return; - Bsprintf(d, "edemo%d.edm", demonum++); - g_demo_filePtr = fopen(d, "rb"); + + if (g_modDir[0] != '/') + Bsprintf(d,"%s/edemo%d.edm",g_modDir, demonum++); + else Bsprintf(d, "edemo%d.edm", demonum++); + + g_demo_filePtr = Bfopen(d, "rb"); if (g_demo_filePtr == NULL) break; Bfclose(g_demo_filePtr); } + while (1); - if ((g_demo_filePtr = fopen(d,"wb")) == NULL) return; + if ((g_demo_filePtr = Bfopen(d,"wb")) == NULL) return; i=sv_saveandmakesnapshot(g_demo_filePtr, demorec_diffs_cvar, demorec_diffcompress_cvar, demorec_synccompress_cvar|(demorec_seeds_cvar<<1)); if (i) { - Bstrcpy(ScriptQuotes[122], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS."); - P_DoQuote(122, g_player[myconnectindex].ps); + Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS."); + P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps); Bfclose(g_demo_filePtr), g_demo_filePtr=NULL; ud.recstat = ud.m_recstat = 0; return; @@ -189,8 +194,8 @@ void G_OpenDemoWrite(void) demo_synccompress = demorec_synccompress_cvar; demorec_difftics = demorec_difftics_cvar; - Bstrcpy(ScriptQuotes[122], "DEMO RECORDING STARTED"); - P_DoQuote(122, g_player[myconnectindex].ps); + Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "DEMO RECORDING STARTED"); + P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps); ud.reccnt = 0; ud.recstat = ud.m_recstat = 1; // @@ -269,8 +274,8 @@ void G_CloseDemoWrite(void) sv_freemem(); - Bstrcpy(ScriptQuotes[122], "DEMO RECORDING STOPPED"); - P_DoQuote(122, g_player[myconnectindex].ps); + Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "DEMO RECORDING STOPPED"); + P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps); } #if KRANDDEBUG krd_print("krandrec.log"); diff --git a/polymer-perf/eduke32/source/duke3d.h b/polymer-perf/eduke32/source/duke3d.h index eed42678c..b926975d6 100644 --- a/polymer-perf/eduke32/source/duke3d.h +++ b/polymer-perf/eduke32/source/duke3d.h @@ -35,7 +35,7 @@ extern "C" { #ifdef POLYMER #include "polymer.h" #else -#ifdef POLYMOST +#ifdef USE_OPENGL #include "polymost.h" #endif #endif @@ -52,19 +52,19 @@ extern "C" { #define VERSION "2.0.0devel" #define HEAD2 APPNAME" "VERSION -#define GAMEDUKE 0 -#define GAMENAM 1 -#define GAMEWW2 3 +#define GAME_DUKE 0 +#define GAME_NAM 1 +#define GAME_WW2 3 #define VOLUMEALL (g_Shareware == 0) #define PLUTOPAK (g_scriptVersion == 14) #define VOLUMEONE (g_Shareware == 1) -#define NAM (g_gameType & 1) -#define WW2GI (g_gameType & 2) +#define NAM (g_gameType & GAME_NAM) +#define WW2GI (g_gameType & GAME_WW2) // increase by 3, because atomic GRP adds 1, and Shareware adds 2 -#define BYTEVERSION_JF 195 +#define BYTEVERSION_JF 198 #define BYTEVERSION_13 27 #define BYTEVERSION_14 116 #define BYTEVERSION_15 117 @@ -86,15 +86,10 @@ extern "C" { #define TICSPERFRAME 4 #define TICRATE 120 -#define MAXQUOTES 16384 -#define MAXQUOTELEN 128 -#define OBITQUOTEINDEX MAXQUOTES-128 -#define SUICIDEQUOTEINDEX MAXQUOTES-32 - #define NO 0 #define YES 1 -#define PACKBUF_SIZE 65535 +#define PACKBUF_SIZE 2048 #define TILE_SAVESHOT (MAXTILES-1) #define TILE_LOADSHOT (MAXTILES-3) @@ -118,6 +113,7 @@ extern "C" { #include "music.h" #include "player.h" #include "actors.h" +#include "quotes.h" #include "global.h" #include "sector.h" #include "net.h" diff --git a/polymer-perf/eduke32/source/enet/include/enet/enet.h b/polymer-perf/eduke32/source/enet/include/enet/enet.h index 2f656d6cb..b572590ec 100644 --- a/polymer-perf/eduke32/source/enet/include/enet/enet.h +++ b/polymer-perf/eduke32/source/enet/include/enet/enet.h @@ -25,7 +25,7 @@ extern "C" #define ENET_VERSION_MAJOR 1 #define ENET_VERSION_MINOR 3 -#define ENET_VERSION_PATCH 0 +#define ENET_VERSION_PATCH 1 #define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch)) #define ENET_VERSION ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR, ENET_VERSION_PATCH) diff --git a/polymer-perf/eduke32/source/enet/src/protocol.c b/polymer-perf/eduke32/source/enet/src/protocol.c index d267de564..39d95bc52 100644 --- a/polymer-perf/eduke32/source/enet/src/protocol.c +++ b/polymer-perf/eduke32/source/enet/src/protocol.c @@ -9,9 +9,9 @@ #include "enet/time.h" #include "enet/enet.h" -#ifndef UNREFERENCED_PARAMETER -# define UNREFERENCED_PARAMETER(x) x=x -#endif +#ifndef UNREFERENCED_PARAMETER +# define UNREFERENCED_PARAMETER(x) x=x +#endif static size_t commandSizes [ENET_PROTOCOL_COMMAND_COUNT] = { @@ -178,6 +178,7 @@ enet_protocol_remove_sent_reliable_command (ENetPeer * peer, enet_uint16 reliabl ENetOutgoingCommand * outgoingCommand; ENetListIterator currentCommand; ENetProtocolCommand commandNumber; + int wasSent = 1; for (currentCommand = enet_list_begin (& peer -> sentReliableCommands); currentCommand != enet_list_end (& peer -> sentReliableCommands); @@ -207,6 +208,8 @@ enet_protocol_remove_sent_reliable_command (ENetPeer * peer, enet_uint16 reliabl if (currentCommand == enet_list_end (& peer -> outgoingReliableCommands)) return ENET_PROTOCOL_COMMAND_NONE; + + wasSent = 0; } if (channelID < peer -> channelCount) @@ -227,7 +230,8 @@ enet_protocol_remove_sent_reliable_command (ENetPeer * peer, enet_uint16 reliabl if (outgoingCommand -> packet != NULL) { - peer -> reliableDataInTransit -= outgoingCommand -> fragmentLength; + if (wasSent) + peer -> reliableDataInTransit -= outgoingCommand -> fragmentLength; -- outgoingCommand -> packet -> referenceCount; @@ -256,6 +260,7 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet size_t channelCount; ENetPeer * currentPeer; ENetProtocol verifyCommand; + UNREFERENCED_PARAMETER(header); channelCount = ENET_NET_TO_HOST_32 (command -> connect.channelCount); @@ -611,9 +616,10 @@ enet_protocol_handle_send_fragment (ENetHost * host, ENetPeer * peer, const ENet static int enet_protocol_handle_ping (ENetHost * host, ENetPeer * peer, const ENetProtocol * command) { - UNREFERENCED_PARAMETER(host); - UNREFERENCED_PARAMETER(peer); - UNREFERENCED_PARAMETER(command); + UNREFERENCED_PARAMETER(host); + UNREFERENCED_PARAMETER(peer); + UNREFERENCED_PARAMETER(command); + return 0; } @@ -642,7 +648,7 @@ static int enet_protocol_handle_throttle_configure (ENetHost * host, ENetPeer * peer, const ENetProtocol * command) { UNREFERENCED_PARAMETER(host); - + peer -> packetThrottleInterval = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleInterval); peer -> packetThrottleAcceleration = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleAcceleration); peer -> packetThrottleDeceleration = ENET_NET_TO_HOST_32 (command -> throttleConfigure.packetThrottleDeceleration); @@ -758,7 +764,7 @@ enet_protocol_handle_acknowledge (ENetHost * host, ENetEvent * event, ENetPeer * enet_peer_disconnect (peer, peer -> eventData); break; default: - break; + break; } return 0; @@ -1266,7 +1272,7 @@ enet_protocol_check_timeouts (ENetHost * host, ENetPeer * peer, ENetEvent * even return 0; } -static void +static int enet_protocol_send_reliable_outgoing_commands (ENetHost * host, ENetPeer * peer) { ENetProtocol * command = & host -> commands [host -> commandCount]; @@ -1276,6 +1282,7 @@ enet_protocol_send_reliable_outgoing_commands (ENetHost * host, ENetPeer * peer) ENetChannel *channel; enet_uint16 reliableWindow; size_t commandSize; + int windowExceeded = 0, windowWrap = 0, canPing = 1; currentCommand = enet_list_begin (& peer -> outgoingReliableCommands); @@ -1285,39 +1292,54 @@ enet_protocol_send_reliable_outgoing_commands (ENetHost * host, ENetPeer * peer) channel = outgoingCommand -> command.header.channelID < peer -> channelCount ? & peer -> channels [outgoingCommand -> command.header.channelID] : NULL; reliableWindow = outgoingCommand -> reliableSequenceNumber / ENET_PEER_RELIABLE_WINDOW_SIZE; - if (channel != NULL && - outgoingCommand -> sendAttempts < 1 && - ! (outgoingCommand -> reliableSequenceNumber % ENET_PEER_RELIABLE_WINDOW_SIZE) && - (channel -> reliableWindows [(reliableWindow + ENET_PEER_RELIABLE_WINDOWS - 1) % ENET_PEER_RELIABLE_WINDOWS] >= ENET_PEER_RELIABLE_WINDOW_SIZE || - channel -> usedReliableWindows & ((((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) << reliableWindow) | - (((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOW_SIZE - reliableWindow))))) - break; - + if (channel != NULL) + { + if (! windowWrap && + outgoingCommand -> sendAttempts < 1 && + ! (outgoingCommand -> reliableSequenceNumber % ENET_PEER_RELIABLE_WINDOW_SIZE) && + (channel -> reliableWindows [(reliableWindow + ENET_PEER_RELIABLE_WINDOWS - 1) % ENET_PEER_RELIABLE_WINDOWS] >= ENET_PEER_RELIABLE_WINDOW_SIZE || + channel -> usedReliableWindows & ((((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) << reliableWindow) | + (((1 << ENET_PEER_FREE_RELIABLE_WINDOWS) - 1) >> (ENET_PEER_RELIABLE_WINDOW_SIZE - reliableWindow))))) + windowWrap = 1; + if (windowWrap) + { + currentCommand = enet_list_next (currentCommand); + + continue; + } + } + + if (outgoingCommand -> packet != NULL) + { + if (! windowExceeded) + { + enet_uint32 windowSize = (peer -> packetThrottle * peer -> windowSize) / ENET_PEER_PACKET_THROTTLE_SCALE; + + if (peer -> reliableDataInTransit + outgoingCommand -> fragmentLength > ENET_MAX (windowSize, peer -> mtu)) + windowExceeded = 1; + } + if (windowExceeded) + { + currentCommand = enet_list_next (currentCommand); + + continue; + } + } + + canPing = 0; + commandSize = commandSizes [outgoingCommand -> command.header.command & ENET_PROTOCOL_COMMAND_MASK]; if (command >= & host -> commands [sizeof (host -> commands) / sizeof (ENetProtocol)] || buffer + 1 >= & host -> buffers [sizeof (host -> buffers) / sizeof (ENetBuffer)] || - peer -> mtu - host -> packetSize < commandSize) + peer -> mtu - host -> packetSize < commandSize || + (outgoingCommand -> packet != NULL && + (enet_uint16) (peer -> mtu - host -> packetSize) < (enet_uint16) (commandSize + outgoingCommand -> fragmentLength))) { host -> continueSending = 1; break; } - if (outgoingCommand -> packet != NULL) - { - enet_uint32 windowSize = (peer -> packetThrottle * peer -> windowSize) / ENET_PEER_PACKET_THROTTLE_SCALE; - - if (peer -> reliableDataInTransit + outgoingCommand -> fragmentLength > ENET_MAX (windowSize, peer -> mtu)) - break; - - if ((enet_uint16) (peer -> mtu - host -> packetSize) < (enet_uint16) (commandSize + outgoingCommand -> fragmentLength)) - { - host -> continueSending = 1; - - break; - } - } - currentCommand = enet_list_next (currentCommand); if (channel != NULL && outgoingCommand -> sendAttempts < 1) @@ -1370,6 +1392,8 @@ enet_protocol_send_reliable_outgoing_commands (ENetHost * host, ENetPeer * peer) host -> commandCount = command - host -> commands; host -> bufferCount = buffer - host -> buffers; + + return canPing; } static int @@ -1407,10 +1431,9 @@ enet_protocol_send_outgoing_commands (ENetHost * host, ENetEvent * event, int ch enet_protocol_check_timeouts (host, currentPeer, event) == 1) return 1; - if (! enet_list_empty (& currentPeer -> outgoingReliableCommands)) - enet_protocol_send_reliable_outgoing_commands (host, currentPeer); - else - if (enet_list_empty (& currentPeer -> sentReliableCommands) && + if ((enet_list_empty (& currentPeer -> outgoingReliableCommands) || + enet_protocol_send_reliable_outgoing_commands (host, currentPeer)) && + enet_list_empty (& currentPeer -> sentReliableCommands) && ENET_TIME_DIFFERENCE (host -> serviceTime, currentPeer -> lastReceiveTime) >= ENET_PEER_PING_INTERVAL && currentPeer -> mtu - host -> packetSize >= sizeof (ENetProtocolPing)) { diff --git a/polymer-perf/eduke32/source/game.c b/polymer-perf/eduke32/source/game.c index b5e203985..4a21fd370 100644 --- a/polymer-perf/eduke32/source/game.c +++ b/polymer-perf/eduke32/source/game.c @@ -71,6 +71,7 @@ extern int32_t G_GetVersionFromWebsite(char *buffer); #define UPDATEINTERVAL 604800 // 1w #else static int32_t usecwd = 0; +#include #endif /* _WIN32 */ int32_t g_quitDeadline = 0; @@ -528,7 +529,7 @@ void G_HandleSpecialKeys(void) // CONTROL_ProcessBinds(); - if (ALT_IS_PRESSED && KB_KeyPressed(sc_Enter)) + if (g_networkMode != NET_DEDICATED_SERVER && ALT_IS_PRESSED && KB_KeyPressed(sc_Enter)) { if (setgamemode(!ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP)) { @@ -546,7 +547,7 @@ void G_HandleSpecialKeys(void) { KB_ClearKeyDown(sc_F12); screencapture("duke0000.tga",0); - P_DoQuote(103,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_SCREEN_SAVED,g_player[myconnectindex].ps); } // only dispatch commands here when not in a game @@ -1695,7 +1696,7 @@ static void G_PrintCoords(int32_t snum) printext256(250L,y,31,-1,tempbuf,0); Bsprintf(tempbuf,"A/H= %d,%d",g_player[snum].ps->ang,g_player[snum].ps->horiz); printext256(250L,y+9L,31,-1,tempbuf,0); - Bsprintf(tempbuf,"ZV= %d",g_player[snum].ps->posvel.z); + Bsprintf(tempbuf,"ZV= %d",g_player[snum].ps->vel.z); printext256(250L,y+18L,31,-1,tempbuf,0); Bsprintf(tempbuf,"OG= %d",g_player[snum].ps->on_ground); printext256(250L,y+27L,31,-1,tempbuf,0); @@ -1727,7 +1728,7 @@ void G_PrintGameQuotes(void) else if (j > 12) k += 24; } - if (g_player[screenpeek].ps->fta > 1 && (g_player[screenpeek].ps->ftq < 115 || g_player[screenpeek].ps->ftq > 117)) + if (g_player[screenpeek].ps->fta > 1 && (g_player[screenpeek].ps->ftq < QUOTE_RESERVED || g_player[screenpeek].ps->ftq > QUOTE_RESERVED3)) { if (g_player[screenpeek].ps->fta > 6) k += 7; @@ -1778,7 +1779,7 @@ void G_PrintGameQuotes(void) k = 0; - if (g_player[screenpeek].ps->ftq == 115 || g_player[screenpeek].ps->ftq == 116 || g_player[screenpeek].ps->ftq == 117) + if (g_player[screenpeek].ps->ftq >= QUOTE_RESERVED && g_player[screenpeek].ps->ftq <= QUOTE_RESERVED3) { k = 140;//quotebot-8-4; } @@ -1826,8 +1827,8 @@ void P_DoQuote(int32_t q, DukePlayer_t *p) if (ud.fta_on == 0) return; - if (p->fta > 0 && q != 115 && q != 116) - if (p->ftq == 115 || p->ftq == 116) return; + if (p->fta > 0 && q != QUOTE_RESERVED && q != QUOTE_RESERVED2) + if (p->ftq == QUOTE_RESERVED || p->ftq == QUOTE_RESERVED2) return; p->fta = 100; @@ -1997,7 +1998,7 @@ void G_GameExit(const char *t) if (!(t[0] == ' ' && t[1] == 0)) { char titlebuf[256]; - Bsprintf(titlebuf,HEAD2 " %s",s_buildDate); + Bsprintf(titlebuf,HEAD2 " %s",s_buildRev); wm_msgbox(titlebuf, "%s", (char *)t); } } @@ -2479,7 +2480,7 @@ void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b) makepalookup(CROSSHAIR_PAL,tempbuf,CrosshairColors.r>>2, CrosshairColors.g>>2, CrosshairColors.b>>2,1); -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL Bmemcpy(&hictinting[CROSSHAIR_PAL], &CrosshairColors, sizeof(palette_t)); hictinting[CROSSHAIR_PAL].f = 9; #endif @@ -2535,7 +2536,7 @@ void G_DisplayRest(int32_t smoothratio) walltype *wal; int32_t cposx, cposy, cang; -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL // this takes care of fullscreen tint for OpenGL if (getrendermode() >= 3) @@ -2791,7 +2792,7 @@ void G_DisplayRest(int32_t smoothratio) if (ud.coords) G_PrintCoords(screenpeek); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL { extern int32_t mdpause; @@ -3220,6 +3221,8 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) int32_t tmpyx=yxaspect, tmpvr=viewingrange; + if (g_networkMode == NET_DEDICATED_SERVER) return; + if (pub > 0 || getrendermode() >= 3) // JBF 20040101: redraw background always { if (getrendermode() >= 3 || ud.screen_size > 8 || (ud.screen_size == 8 && ud.statusbarscale<100)) @@ -3345,7 +3348,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) } else if (getrendermode() > 0 && ud.screen_tilting /*&& (p->rotscrnang || p->orotscrnang)*/) { -#ifdef POLYMOST +#ifdef USE_OPENGL setrollangle(p->orotscrnang + mulscale16(((p->rotscrnang - p->orotscrnang + 1024)&2047)-1024,smoothratio)); #endif p->orotscrnang = p->rotscrnang; // JBF: save it for next time @@ -3416,7 +3419,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) VM_OnEvent(EVENT_DISPLAYROOMS, g_player[screenpeek].ps->i, screenpeek, -1); if (((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0) -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL && (getrendermode() != 4) #endif ) @@ -5633,7 +5636,7 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio) t->xrepeat = t->yrepeat = 0; continue; case CHAIR3__STATIC: -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (getrendermode() >= 3 && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { t->cstat &= ~4; @@ -5899,7 +5902,7 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio) t->picnum = GROWSPARK+((totalclock>>4)&3); break; case RPG__STATIC: -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (getrendermode() >= 3 && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags & SPREXT_NOTMD)) { @@ -5922,7 +5925,7 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio) case RECON__STATIC: -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (getrendermode() >= 3 && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { t->cstat &= ~4; @@ -5962,7 +5965,7 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio) } else*/ t->ang = g_player[p].ps->ang+mulscale16((int32_t)(((g_player[p].ps->ang+1024- g_player[p].ps->oang)&2047)-1024),smoothratio); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (bpp > 8 && usemodels && md_tilehasmodel(t->picnum, t->pal) >= 0) { static int32_t targetang = 0; @@ -6043,7 +6046,7 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio) if (s->owner == -1) { -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (getrendermode() >= 3 && usemodels && md_tilehasmodel(s->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { k = 0; @@ -6098,7 +6101,7 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio) continue; } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (getrendermode() >= 3 && usemodels && md_tilehasmodel(s->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { k = 0; @@ -6192,77 +6195,77 @@ PALONLY: t->ang = sprpos[i].ang; } */ + if ((unsigned)((intptr_t *)t4-&script[0]) > (unsigned)(&script[g_scriptSize]-&script[0])) + goto skip; + + l = *(((intptr_t *)t4)+2); //For TerminX: was *(int32_t *)(t4+8) - if ((intptr_t *)t4 >= &script[0] && (intptr_t *)t4 <= (&script[0]+g_scriptSize)) +#ifdef USE_OPENGL + if (getrendermode() >= 3 && usemodels && md_tilehasmodel(s->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { - l = *(((intptr_t *)t4)+2); //For TerminX: was *(int32_t *)(t4+8) - -#if defined(POLYMOST) && defined(USE_OPENGL) - if (getrendermode() >= 3 && usemodels && md_tilehasmodel(s->picnum,t->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) - { - k = 0; - t->cstat &= ~4; - } - else -#endif - switch (l) - { - case 2: - k = (((s->ang+3072+128-a)&2047)>>8)&1; - break; - - case 3: - case 4: - k = (((s->ang+3072+128-a)&2047)>>7)&7; - if (k > 3) - { - t->cstat |= 4; - k = 7-k; - } - else t->cstat &= ~4; - break; - - case 5: - k = getangle(s->x-x,s->y-y); - k = (((s->ang+3072+128-k)&2047)>>8)&7; - if (k>4) - { - k = 8-k; - t->cstat |= 4; - } - else t->cstat &= ~4; - break; - case 7: - k = getangle(s->x-x,s->y-y); - k = (((s->ang+3072+128-k)&2047)/170); - if (k>6) - { - k = 12-k; - t->cstat |= 4; - } - else t->cstat &= ~4; - break; - case 8: - k = (((s->ang+3072+128-a)&2047)>>8)&7; - t->cstat &= ~4; - break; - default: - k = 0; - break; - } - - t->picnum += k + (*(intptr_t *)t4) + l * t3; - - if (l > 0) while (tilesizx[t->picnum] == 0 && t->picnum > 0) - t->picnum -= l; //Hack, for actors - - if (actor[i].dispicnum >= 0) - actor[i].dispicnum = t->picnum; + k = 0; + t->cstat &= ~4; } - else if (display_mirror == 1) - t->cstat |= 4; - } + else +#endif + switch (l) + { + case 2: + k = (((s->ang+3072+128-a)&2047)>>8)&1; + break; + case 3: + case 4: + k = (((s->ang+3072+128-a)&2047)>>7)&7; + if (k > 3) + { + t->cstat |= 4; + k = 7-k; + } + else t->cstat &= ~4; + break; + + case 5: + k = getangle(s->x-x,s->y-y); + k = (((s->ang+3072+128-k)&2047)>>8)&7; + if (k>4) + { + k = 8-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + break; + case 7: + k = getangle(s->x-x,s->y-y); + k = (((s->ang+3072+128-k)&2047)/170); + if (k>6) + { + k = 12-k; + t->cstat |= 4; + } + else t->cstat &= ~4; + break; + case 8: + k = (((s->ang+3072+128-a)&2047)>>8)&7; + t->cstat &= ~4; + break; + default: + k = 0; + break; + } + + t->picnum += k + (*(intptr_t *)t4) + l * t3; + + if (l > 0) while (tilesizx[t->picnum] == 0 && t->picnum > 0) + t->picnum -= l; //Hack, for actors + + if (actor[i].dispicnum >= 0) + actor[i].dispicnum = t->picnum; + } + else if (display_mirror == 1) + t->cstat |= 4; + +skip: if (g_player[screenpeek].ps->inv_amount[GET_HEATS] > 0 && g_player[screenpeek].ps->heat_on && (A_CheckEnemySprite(s) || A_CheckSpriteFlags(t->owner,SPRITE_NVG) || s->picnum == APLAYER || s->statnum == STAT_DUMMYPLAYER)) { @@ -6309,7 +6312,7 @@ PALONLY: yrep = tsprite[spritesortcnt].yrepeat;// - (klabs(daz-t->z)>>11); tsprite[spritesortcnt].yrepeat = yrep; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (getrendermode() >= 3 && usemodels && md_tilehasmodel(t->picnum,t->pal) >= 0) { tsprite[spritesortcnt].yrepeat = 0; @@ -6362,6 +6365,7 @@ PALONLY: break; case FIRE__STATIC: case FIRE2__STATIC: + t->cstat |= 128; case BURNING__STATIC: case BURNING2__STATIC: if (sprite[s->owner].picnum != TREE1 && sprite[s->owner].picnum != TREE2) @@ -6376,7 +6380,7 @@ PALONLY: t->picnum += (s->shade>>1); break; case PLAYERONWATER__STATIC: -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (getrendermode() >= 3 && usemodels && md_tilehasmodel(s->picnum,s->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { k = 0; @@ -6439,7 +6443,7 @@ PALONLY: case CAMERA1__STATIC: case RAT__STATIC: -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (getrendermode() >= 3 && usemodels && md_tilehasmodel(s->picnum,s->pal) >= 0 && !(spriteext[i].flags&SPREXT_NOTMD)) { t->cstat &= ~4; @@ -6661,7 +6665,7 @@ GAME_STATIC void G_DoCheats(void) if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9'))) { g_player[myconnectindex].ps->cheat_phase = 0; - // P_DoQuote(46,g_player[myconnectindex].ps); + // P_DoQuote(QUOTE_46,g_player[myconnectindex].ps); return; } @@ -6709,14 +6713,14 @@ FOUNDCHEAT: KB_FlushKeyBoardQueue(); g_player[myconnectindex].ps->cheat_phase = 0; - P_DoQuote(119,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_ALL_WEAPONS, g_player[myconnectindex].ps); return; case CHEAT_INVENTORY: KB_FlushKeyBoardQueue(); g_player[myconnectindex].ps->cheat_phase = 0; G_CheatGetInv(); - P_DoQuote(120,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_ALL_INV, g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; return; @@ -6724,7 +6728,7 @@ FOUNDCHEAT: g_player[myconnectindex].ps->got_access = 7; KB_FlushKeyBoardQueue(); g_player[myconnectindex].ps->cheat_phase = 0; - P_DoQuote(121,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_ALL_KEYS, g_player[myconnectindex].ps); return; case CHEAT_DEBUG: @@ -6743,7 +6747,7 @@ FOUNDCHEAT: ud.clipping = 1-ud.clipping; KB_FlushKeyBoardQueue(); g_player[myconnectindex].ps->cheat_phase = 0; - P_DoQuote(112+ud.clipping,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_NOCLIP-ud.clipping, g_player[myconnectindex].ps); return; case CHEAT_RESERVED2: @@ -6753,7 +6757,7 @@ FOUNDCHEAT: return; case CHEAT_ALLEN: - P_DoQuote(79,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_ALLEN,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_ClearKeyDown(sc_N); return; @@ -6779,7 +6783,7 @@ FOUNDCHEAT: sprite[g_player[myconnectindex].ps->i].lotag = 0; sprite[g_player[myconnectindex].ps->i].pal = g_player[myconnectindex].ps->palookup; - P_DoQuote(17,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_GODMODE_ON,g_player[myconnectindex].ps); } else { @@ -6787,7 +6791,7 @@ FOUNDCHEAT: sprite[g_player[myconnectindex].ps->i].extra = g_player[myconnectindex].ps->max_player_health; actor[g_player[myconnectindex].ps->i].extra = -1; g_player[myconnectindex].ps->last_extra = g_player[myconnectindex].ps->max_player_health; - P_DoQuote(18,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_GODMODE_OFF,g_player[myconnectindex].ps); } sprite[g_player[myconnectindex].ps->i].extra = g_player[myconnectindex].ps->max_player_health; @@ -6816,9 +6820,9 @@ FOUNDCHEAT: sprite[g_player[myconnectindex].ps->i].hitag = 0; sprite[g_player[myconnectindex].ps->i].lotag = 0; sprite[g_player[myconnectindex].ps->i].pal = g_player[myconnectindex].ps->palookup; - Bstrcpy(ScriptQuotes[122],"COME GET SOME!"); + Bstrcpy(ScriptQuotes[QUOTE_RESERVED4],"COME GET SOME!"); S_PlaySound(DUKE_GETWEAPON2); - P_DoQuote(122,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps); G_CheatGetInv(); for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++) g_player[myconnectindex].ps->gotweapon |= (1<i].extra = g_player[myconnectindex].ps->max_player_health; actor[g_player[myconnectindex].ps->i].extra = -1; g_player[myconnectindex].ps->last_extra = g_player[myconnectindex].ps->max_player_health; - P_DoQuote(18,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_GODMODE_OFF, g_player[myconnectindex].ps); } sprite[g_player[myconnectindex].ps->i].extra = g_player[myconnectindex].ps->max_player_health; @@ -6859,10 +6863,10 @@ FOUNDCHEAT: P_AddAmmo(weapon, g_player[myconnectindex].ps, g_player[myconnectindex].ps->max_ammo_amount[weapon]); G_CheatGetInv(); g_player[myconnectindex].ps->got_access = 7; - P_DoQuote(5,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_EVERYTHING, g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; - // P_DoQuote(21,g_player[myconnectindex].ps); + // P_DoQuote(QUOTE_21,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); g_player[myconnectindex].ps->inven_icon = 1; @@ -6937,14 +6941,14 @@ FOUNDCHEAT: g_cameraDistance = 0; g_cameraClock = totalclock; } - P_DoQuote(22,g_player[myconnectindex].ps); +// P_DoQuote(QUOTE_CHEATS_DISABLED,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; case CHEAT_TIME: - P_DoQuote(21,g_player[myconnectindex].ps); +// P_DoQuote(QUOTE_21,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; @@ -6965,7 +6969,7 @@ FOUNDCHEAT: } G_OperateForceFields(g_player[myconnectindex].ps->i,-1); - P_DoQuote(100,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_UNLOCK,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; @@ -6979,7 +6983,7 @@ FOUNDCHEAT: case CHEAT_ITEMS: G_CheatGetInv(); g_player[myconnectindex].ps->got_access = 7; - P_DoQuote(5,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_EVERYTHING,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; @@ -6992,7 +6996,7 @@ FOUNDCHEAT: show2dsector[i] = 255; for (i=0; i<(MAXWALLS>>3); i++) show2dwall[i] = 255; - P_DoQuote(111,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_SHOW_MAP_ON, g_player[myconnectindex].ps); } else { @@ -7000,14 +7004,14 @@ FOUNDCHEAT: show2dsector[i] = 0; for (i=0; i<(MAXWALLS>>3); i++) show2dwall[i] = 0; - P_DoQuote(1,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_SHOW_MAP_OFF, g_player[myconnectindex].ps); } g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; case CHEAT_TODD: - P_DoQuote(99,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_TODD,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); return; @@ -7019,7 +7023,7 @@ FOUNDCHEAT: return; case CHEAT_BETA: - P_DoQuote(105,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_BETA,g_player[myconnectindex].ps); KB_ClearKeyDown(sc_H); g_player[myconnectindex].ps->cheat_phase = 0; KB_FlushKeyBoardQueue(); @@ -7029,19 +7033,22 @@ FOUNDCHEAT: g_player[myconnectindex].ps->inv_amount[GET_STEROIDS] = 399; g_player[myconnectindex].ps->inv_amount[GET_HEATS] = 1200; g_player[myconnectindex].ps->cheat_phase = 0; - P_DoQuote(37,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEAT_STEROIDS,g_player[myconnectindex].ps); KB_FlushKeyBoardQueue(); return; case CHEAT_MONSTERS: { - char *s[] = { "ON", "OFF", "ON" }; + char *s[] = { "ON", "OFF" }; + + if (++g_noEnemies == 3) + g_noEnemies = 0; - g_noEnemies++; - if (g_noEnemies == 3) g_noEnemies = 0; g_player[screenpeek].ps->cheat_phase = 0; - Bsprintf(ScriptQuotes[122],"MONSTERS: %s",s[(uint8_t)g_noEnemies]); - P_DoQuote(122,g_player[myconnectindex].ps); + + Bsprintf(ScriptQuotes[QUOTE_RESERVED4], "MONSTERS: %s", s[g_noEnemies%1]); + P_DoQuote(QUOTE_RESERVED4,g_player[myconnectindex].ps); + KB_FlushKeyBoardQueue(); return; } @@ -7073,13 +7080,13 @@ FOUNDCHEAT: { if (ud.player_skill == 4) { - P_DoQuote(22,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_CHEATS_DISABLED,g_player[myconnectindex].ps); g_player[myconnectindex].ps->cheat_phase = 0; } else { g_player[myconnectindex].ps->cheat_phase = 1; - // P_DoQuote(25,g_player[myconnectindex].ps); + // P_DoQuote(QUOTE_25,g_player[myconnectindex].ps); cheatbuflen = 0; } KB_FlushKeyboardQueue(); @@ -7192,14 +7199,14 @@ void G_HandleLocalKeys(void) { CONTROL_ClearButton(gamefunc_Show_Opponents_Weapon); ud.config.ShowOpponentWeapons = ud.showweapons = 1-ud.showweapons; - P_DoQuote(82-ud.showweapons,g_player[screenpeek].ps); + P_DoQuote(QUOTE_WEAPON_MODE_OFF-ud.showweapons,g_player[screenpeek].ps); } if (BUTTON(gamefunc_Toggle_Crosshair)) { CONTROL_ClearButton(gamefunc_Toggle_Crosshair); ud.crosshair = !ud.crosshair; - P_DoQuote(21-ud.crosshair,g_player[screenpeek].ps); + P_DoQuote(QUOTE_CROSSHAIR_OFF-ud.crosshair,g_player[screenpeek].ps); } if (ud.overhead_on && BUTTON(gamefunc_Map_Follow_Mode)) @@ -7212,7 +7219,7 @@ void G_HandleLocalKeys(void) ud.foly = g_player[screenpeek].ps->opos.y; ud.fola = g_player[screenpeek].ps->oang; } - P_DoQuote(83+ud.scrollmode,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_MAP_FOLLOW_OFF+ud.scrollmode,g_player[myconnectindex].ps); } if (KB_UnBoundKeyPressed(sc_ScrollLock)) @@ -7338,7 +7345,7 @@ void G_HandleLocalKeys(void) { if (SHIFTS_IS_PRESSED) { - if (i == 5 && g_player[myconnectindex].ps->fta > 0 && g_player[myconnectindex].ps->ftq == 26) + if (i == 5 && g_player[myconnectindex].ps->fta > 0 && g_player[myconnectindex].ps->ftq == QUOTE_MUSIC) { i = (VOLUMEALL?MAXVOLUMES*MAXLEVELS:6); g_musicIndex = (g_musicIndex+1)%i; @@ -7351,10 +7358,10 @@ void G_HandleLocalKeys(void) if (MapInfo[(uint8_t)g_musicIndex].musicfn != NULL) { if (S_PlayMusic(&MapInfo[(uint8_t)g_musicIndex].musicfn[0],g_musicIndex)) - Bsprintf(ScriptQuotes[26],"PLAYING %s",&MapInfo[(uint8_t)g_musicIndex].alt_musicfn[0]); + Bsprintf(ScriptQuotes[QUOTE_MUSIC],"PLAYING %s",&MapInfo[(uint8_t)g_musicIndex].alt_musicfn[0]); else - Bsprintf(ScriptQuotes[26],"PLAYING %s",&MapInfo[(uint8_t)g_musicIndex].musicfn[0]); - P_DoQuote(26,g_player[myconnectindex].ps); + Bsprintf(ScriptQuotes[QUOTE_MUSIC],"PLAYING %s",&MapInfo[(uint8_t)g_musicIndex].musicfn[0]); + P_DoQuote(QUOTE_MUSIC,g_player[myconnectindex].ps); } return; } @@ -7473,7 +7480,7 @@ void G_HandleLocalKeys(void) FAKE_F2: if (sprite[g_player[myconnectindex].ps->i].extra <= 0) { - P_DoQuote(118,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_SAVE_DEAD,g_player[myconnectindex].ps); return; } ChangeToMenu(350); @@ -7542,7 +7549,7 @@ FAKE_F3: if (sprite[g_player[myconnectindex].ps->i].extra <= 0) { - P_DoQuote(118,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_SAVE_DEAD,g_player[myconnectindex].ps); return; } g_screenCapture = 1; @@ -7571,32 +7578,32 @@ FAKE_F3: g_cameraDistance = 0; g_cameraClock = totalclock; } - P_DoQuote(109+g_player[myconnectindex].ps->over_shoulder_on,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_VIEW_MODE_OFF+g_player[myconnectindex].ps->over_shoulder_on,g_player[myconnectindex].ps); } if (KB_UnBoundKeyPressed(sc_F5) && ud.config.MusicDevice >= 0) { KB_ClearKeyDown(sc_F5); if (MapInfo[(uint8_t)g_musicIndex].alt_musicfn != NULL) - Bstrcpy(ScriptQuotes[26],&MapInfo[(uint8_t)g_musicIndex].alt_musicfn[0]); + Bstrcpy(ScriptQuotes[QUOTE_MUSIC],&MapInfo[(uint8_t)g_musicIndex].alt_musicfn[0]); else if (MapInfo[(uint8_t)g_musicIndex].musicfn != NULL) { - Bstrcpy(ScriptQuotes[26],&MapInfo[(uint8_t)g_musicIndex].musicfn[0]); - Bstrcat(ScriptQuotes[26],". USE SHIFT-F5 TO CHANGE."); + Bstrcpy(ScriptQuotes[QUOTE_MUSIC],&MapInfo[(uint8_t)g_musicIndex].musicfn[0]); + Bstrcat(ScriptQuotes[QUOTE_MUSIC],". USE SHIFT-F5 TO CHANGE."); } - else ScriptQuotes[26][0] = '\0'; - P_DoQuote(26,g_player[myconnectindex].ps); + else ScriptQuotes[QUOTE_MUSIC][0] = '\0'; + P_DoQuote(QUOTE_MUSIC, g_player[myconnectindex].ps); } if (KB_UnBoundKeyPressed(sc_F8)) { KB_ClearKeyDown(sc_F8); ud.fta_on = !ud.fta_on; - if (ud.fta_on) P_DoQuote(23,g_player[myconnectindex].ps); + if (ud.fta_on) P_DoQuote(QUOTE_MESSAGES_ON,g_player[myconnectindex].ps); else { ud.fta_on = 1; - P_DoQuote(24,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_MESSAGES_OFF,g_player[myconnectindex].ps); ud.fta_on = 0; } } @@ -7673,7 +7680,7 @@ FAKE_F3: { CONTROL_ClearButton(gamefunc_AutoRun); ud.auto_run = 1-ud.auto_run; - P_DoQuote(85+ud.auto_run,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_RUN_MODE_OFF+ud.auto_run,g_player[myconnectindex].ps); } if (BUTTON(gamefunc_Map)) @@ -7745,7 +7752,7 @@ static void G_ShowParameterHelp(void) "\nSee eduke32 -debughelp for debug parameters" ; #if defined RENDERTYPEWIN - Bsnprintf(tempbuf, sizeof(tempbuf), HEAD2 " %s", s_buildDate); + Bsnprintf(tempbuf, sizeof(tempbuf), HEAD2 " %s", s_buildRev); wm_msgbox(tempbuf,s); #else initprintf("%s\n",s); @@ -7771,7 +7778,7 @@ static void G_ShowDebugHelp(void) "-conversion YYYYMMDD\tSelects CON script version for compatibility with older mods\n" ; #if defined RENDERTYPEWIN - Bsnprintf(tempbuf, sizeof(tempbuf), HEAD2 " %s", s_buildDate); + Bsnprintf(tempbuf, sizeof(tempbuf), HEAD2 " %s", s_buildRev); wm_msgbox(tempbuf,s); #else initprintf("%s\n",s); @@ -7809,7 +7816,7 @@ static int32_t getfilenames(const char *path, char kind[]) } static char *autoloadmasks[] = { "*.grp", "*.zip", "*.pk3" }; -#define NUMAUTOLOADMASKS 3 +#define NUMAUTOLOADMASKS (int32_t)(sizeof(autoloadmasks)/sizeof(autoloadmasks[0])) static void G_DoAutoload(const char *fn) { @@ -7829,7 +7836,7 @@ static void G_DoAutoload(const char *fn) } } -static char *makename(char *destname, char *OGGname, const char *origname) +static char *S_OggifyFilename(char *destname, char *OGGname, const char *origname) { if (!origname) return destname; @@ -7859,7 +7866,7 @@ static int32_t S_DefineSound(int32_t ID,char *name) { if (ID >= MAXSOUNDS) return 1; - g_sounds[ID].filename1 =makename(g_sounds[ID].filename1,name,g_sounds[ID].filename); + g_sounds[ID].filename1 =S_OggifyFilename(g_sounds[ID].filename1,name,g_sounds[ID].filename); // initprintf("(%s)(%s)(%s)\n",g_sounds[ID].filename1,name,g_sounds[ID].filename); // S_LoadSound(ID); return 0; @@ -7899,7 +7906,7 @@ static int32_t S_DefineMusic(char *ID,char *name) ID = MapInfo[sel].musicfn; } - MapInfo[sel].alt_musicfn = makename(MapInfo[sel].alt_musicfn,name,ID); + MapInfo[sel].alt_musicfn = S_OggifyFilename(MapInfo[sel].alt_musicfn,name,ID); // initprintf("%-15s | ",ID); // initprintf("%3d %2d %2d | %s\n",sel,ep,lev,MapInfo[sel].alt_musicfn); // S_PlayMusic(ID,sel); @@ -8190,14 +8197,14 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) initprintf("\n"); i = 1; - while (i < argc) + do { c = (char *)argv[i]; if ((*c == '-') #ifdef _WIN32 - || (*c == '/') + || (*c == '/') #endif - ) + ) { if (!Bstrcasecmp(c+1,"?") || !Bstrcasecmp(c+1,"help") || !Bstrcasecmp(c+1,"-help")) { @@ -8255,7 +8262,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) Bsprintf(defaultduke3dgrp, "nam.grp"); Bsprintf(defaultduke3ddef, "nam.def"); Bsprintf(defaultconfilename, "nam.con"); - g_gameType = GAMENAM; + g_gameType = GAME_NAM; i++; continue; } @@ -8264,7 +8271,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) Bsprintf(defaultduke3dgrp, "ww2gi.grp"); Bsprintf(defaultduke3ddef, "ww2gi.def"); Bsprintf(defaultconfilename, "ww2gi.con"); - g_gameType = GAMEWW2; + g_gameType = GAME_WW2; i++; continue; } @@ -8318,7 +8325,14 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) } if (!Bstrcasecmp(c+1,"server")) { - g_netServerMode = 1; + g_networkMode = NET_SERVER; + g_noSetup = g_noLogo = TRUE; + i++; + continue; + } + if (!Bstrcasecmp(c+1,"dedicated")) + { + g_networkMode = NET_DEDICATED_SERVER; g_noSetup = g_noLogo = TRUE; i++; continue; @@ -8430,9 +8444,9 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) if ((*c == '-') #ifdef _WIN32 - || (*c == '/') + || (*c == '/') #endif - ) + ) { c++; switch (Btolower(*c)) @@ -8648,6 +8662,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) } i++; } + while (i < argc); } } @@ -8884,7 +8899,7 @@ static void G_Cleanup(void) void G_Shutdown(void) { - CONFIG_WriteSetup(); + CONFIG_WriteSetup(0); S_SoundShutdown(); S_MusicShutdown(); CONTROL_Shutdown(); @@ -9142,7 +9157,7 @@ static void G_Startup(void) } for (i=0; i0) + if ((i = clipmapinfo_load("_clipshape0.map")) > 0) initprintf("There was an error loading the sprite clipping map (status %d).\n", i); OSD_Exec("autoexec.cfg"); - if (setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP) < 0) + if (g_networkMode != NET_DEDICATED_SERVER) { - int32_t i = 0; - int32_t xres[] = {ud.config.ScreenWidth,800,640,320}; - int32_t yres[] = {ud.config.ScreenHeight,600,480,240}; - int32_t bpp[] = {32,16,8}; - - initprintf("Failure setting video mode %dx%dx%d %s! Attempting safer mode...\n", - ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP,ud.config.ScreenMode?"fullscreen":"windowed"); - -#if defined(POLYMOST) && defined(USE_OPENGL) + if (setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP) < 0) { - int32_t j = 0; - while (setgamemode(0,xres[i],yres[i],bpp[j]) < 0) - { - initprintf("Failure setting video mode %dx%dx%d windowed! Attempting safer mode...\n",xres[i],yres[i],bpp[i]); + int32_t i = 0; + int32_t xres[] = {ud.config.ScreenWidth,800,640,320}; + int32_t yres[] = {ud.config.ScreenHeight,600,480,240}; + int32_t bpp[] = {32,16,8}; - if (++j == 3) + initprintf("Failure setting video mode %dx%dx%d %s! Attempting safer mode...\n", + ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP,ud.config.ScreenMode?"fullscreen":"windowed"); + +#ifdef USE_OPENGL + { + int32_t j = 0; + while (setgamemode(0,xres[i],yres[i],bpp[j]) < 0) { - if (++i == 4) - G_GameExit("Unable to set failsafe video mode!"); - j = 0; + initprintf("Failure setting video mode %dx%dx%d windowed! Attempting safer mode...\n",xres[i],yres[i],bpp[i]); + + if (++j == 3) + { + if (++i == 4) + G_GameExit("Unable to set failsafe video mode!"); + j = 0; + } } } - } #else - while (setgamemode(0,xres[i],yres[i],8) < 0) - { - initprintf("Failure setting video mode %dx%dx%d windowed! Attempting safer mode...\n",xres[i],yres[i],8); - i++; - } + while (setgamemode(0,xres[i],yres[i],8) < 0) + { + initprintf("Failure setting video mode %dx%dx%d windowed! Attempting safer mode...\n",xres[i],yres[i],8); + i++; + } #endif - ud.config.ScreenWidth = xres[i]; - ud.config.ScreenHeight = yres[i]; - ud.config.ScreenBPP = bpp[i]; + ud.config.ScreenWidth = xres[i]; + ud.config.ScreenHeight = yres[i]; + ud.config.ScreenBPP = bpp[i]; + } + + setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); + + S_MusicStartup(); + S_SoundStartup(); } - - setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0); - - S_MusicStartup(); - S_SoundStartup(); // loadtmb(); if (ud.warp_on > 1 && (!g_netServer && ud.multimode < 2)) @@ -9939,8 +9961,11 @@ CLEAN_DIRECTORY: MAIN_LOOP_RESTART: - G_GetCrosshairColor(); - G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b); + if (g_networkMode != NET_DEDICATED_SERVER) + { + G_GetCrosshairColor(); + G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b); + } if (ud.warp_on == 0) { @@ -9965,14 +9990,18 @@ MAIN_LOOP_RESTART: Net_WaitForServer(); } - else G_DisplayLogo(); + else if (g_networkMode != NET_DEDICATED_SERVER) + G_DisplayLogo(); - if (G_PlaybackDemo()) + if (g_networkMode != NET_DEDICATED_SERVER) { - FX_StopAllSounds(); - S_ClearSoundLocks(); - g_noLogoAnim = 1; - goto MAIN_LOOP_RESTART; + if (G_PlaybackDemo()) + { + FX_StopAllSounds(); + S_ClearSoundLocks(); + g_noLogoAnim = 1; + goto MAIN_LOOP_RESTART; + } } } else if (ud.warp_on == 1) @@ -10015,19 +10044,51 @@ MAIN_LOOP_RESTART: } sampletimer(); - MUSIC_Update(); Net_GetPackets(); - G_HandleLocalKeys(); // only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo bindsenabled = g_player[myconnectindex].ps->gm & (MODE_GAME|MODE_DEMO); +#ifndef _WIN32 + // stdin -> OSD input for dedicated server + if (g_networkMode == NET_DEDICATED_SERVER) + { + int32_t nb, flag = 1; + char ch; + static uint32_t bufpos = 0; + static char buf[128]; + + ioctl(0, FIONBIO, &flag); + + if ((nb = read(0, &ch, 1)) > 0 && bufpos < sizeof(buf)) + { + if (ch != '\n') + buf[bufpos++] = ch; + + if (ch == '\n' || bufpos >= sizeof(buf)) + { + buf[bufpos] = 0; + OSD_Dispatch(buf); + bufpos = 0; + } + } + } + else +#endif + { + MUSIC_Update(); + G_HandleLocalKeys(); + } + OSD_DispatchQueued(); - if (!(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO)) && totalclock >= ototalclock+TICSPERFRAME) + if (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && totalclock >= ototalclock+TICSPERFRAME) { - CONTROL_ProcessBinds(); - getinput(myconnectindex); + if (g_networkMode != NET_DEDICATED_SERVER) + { + CONTROL_ProcessBinds(); + getinput(myconnectindex); + } avg.fvel += loc.fvel; avg.svel += loc.svel; @@ -10051,23 +10112,34 @@ MAIN_LOOP_RESTART: } */ - j = 0; - do { + int32_t clockbeforetic; + sampletimer(); if (ready2send == 0) break; ototalclock += TICSPERFRAME; - if (((ud.show_help == 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) && - (g_player[myconnectindex].ps->gm&MODE_GAME) && G_MoveLoop()) - j++; - } - while (!(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO)) && totalclock >= ototalclock+TICSPERFRAME); + clockbeforetic = totalclock; + + if (((ud.show_help == 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) && + (g_player[myconnectindex].ps->gm&MODE_GAME)) + G_MoveLoop(); + + sampletimer(); + + if (totalclock - clockbeforetic >= TICSPERFRAME) + { + // computing a tic takes longer than a tic, so we're slowing + // the game down. rather than tightly spinning here, go draw + // a frame since we're fucked anyway + break; + } + } + while (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && totalclock >= ototalclock+TICSPERFRAME); - if (j) continue; } G_DoCheats(); @@ -10094,6 +10166,12 @@ MAIN_LOOP_RESTART: g_multiMapState = NULL; } + if (g_networkMode == NET_DEDICATED_SERVER) + { + idle(); + goto skipframe; + } + if (framewaiting) { framewaiting--; @@ -10128,6 +10206,7 @@ MAIN_LOOP_RESTART: framewaiting++; } +skipframe: if (g_player[myconnectindex].ps->gm&MODE_DEMO) goto MAIN_LOOP_RESTART; } @@ -10146,7 +10225,7 @@ GAME_STATIC GAME_INLINE int32_t G_MoveLoop() int32_t G_DoMoveThings(void) { - int32_t i, j; + int32_t i; ud.camerasprite = -1; lockclock += TICSPERFRAME; @@ -10184,12 +10263,12 @@ int32_t G_DoMoveThings(void) sprite[hitinfo.hitsprite].picnum == APLAYER && sprite[hitinfo.hitsprite].yvel != screenpeek && g_player[sprite[hitinfo.hitsprite].yvel].ps->dead_flag == 0) { - if (g_player[screenpeek].ps->fta == 0 || g_player[screenpeek].ps->ftq == 117) + if (g_player[screenpeek].ps->fta == 0 || g_player[screenpeek].ps->ftq == QUOTE_RESERVED3) { if (ldist(&sprite[g_player[screenpeek].ps->i],&sprite[hitinfo.hitsprite]) < 9216) { - Bsprintf(ScriptQuotes[117],"%s",&g_player[sprite[hitinfo.hitsprite].yvel].user_name[0]); - g_player[screenpeek].ps->fta = 12, g_player[screenpeek].ps->ftq = 117; + Bsprintf(ScriptQuotes[QUOTE_RESERVED3],"%s",&g_player[sprite[hitinfo.hitsprite].yvel].user_name[0]); + g_player[screenpeek].ps->fta = 12, g_player[screenpeek].ps->ftq = QUOTE_RESERVED3; } } else if (g_player[screenpeek].ps->fta > 2) g_player[screenpeek].ps->fta -= 3; @@ -10289,42 +10368,7 @@ int32_t G_DoMoveThings(void) } if (g_netClient) //Slave - { - input_t *nsyn = (input_t *)&inputfifo[0][myconnectindex]; - - packbuf[0] = PACKET_SLAVE_TO_MASTER; - j = 1; - - Bmemcpy(&packbuf[j], &nsyn[0], offsetof(input_t, filler)); - j += offsetof(input_t, filler); - - Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->pos.x, sizeof(vec3_t) * 2); - j += sizeof(vec3_t) * 2; - - Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->posvel.x, sizeof(vec3_t)); - j += sizeof(vec3_t); - - *(int16_t *)&packbuf[j] = g_player[myconnectindex].ps->ang; - j += sizeof(int16_t); - - Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->horiz, sizeof(int16_t) * 2); - j += sizeof(int16_t) * 2; - - i = g_player[myconnectindex].ps->i; - - { - char buf[1024]; - - j = qlz_compress((char *)(packbuf)+1, (char *)buf, j, state_compress); - Bmemcpy((char *)(packbuf)+1, (char *)buf, j); - j++; - } - - packbuf[j++] = myconnectindex; - - enet_peer_send(g_netClientPeer, CHAN_MOVE, enet_packet_create(packbuf, j, 0)); - - } + Net_ClientMove(); return 0; } @@ -10403,6 +10447,9 @@ void G_BonusScreen(int32_t bonusonly) 350, 380,VICTORY1+8,86,59 }; + if (g_networkMode == NET_DEDICATED_SERVER) + return; + Bsprintf(tempbuf, "%s - " APPNAME, g_gameNamePtr); wm_setapptitle(tempbuf); @@ -11190,7 +11237,7 @@ void A_SpawnGlass(int32_t i,int32_t n) for (; n>0; n--) { int32_t k = A_InsertSprite(SECT,SX,SY,SZ-((krand()&16)<<8),GLASSPIECES+(n%3), - krand()&15,36,36,krand()&2047,32+(krand()&63),-512-(krand()&2047),i,5); + krand()&15,36,36,krand()&2047,32+(krand()&63),-512-(krand()&2047),i,5); sprite[k].pal = sprite[i].pal; } } diff --git a/polymer-perf/eduke32/source/game.h b/polymer-perf/eduke32/source/game.h index 509d922bd..7875aef06 100644 --- a/polymer-perf/eduke32/source/game.h +++ b/polymer-perf/eduke32/source/game.h @@ -64,6 +64,17 @@ enum LogoFlags_t { LOGO_TENSCREEN = 0x00000200 }; +typedef enum basepal_ { + BASEPAL = 0, + WATERPAL, + SLIMEPAL, + DREALMSPAL, + TITLEPAL, + ENDINGPAL, + ANIMPAL, + BASEPALCOUNT +} basepal_t; + #define deletesprite A_DeleteSprite void A_DeleteSprite(int32_t s); @@ -227,23 +238,9 @@ extern palette_t DefaultCrosshairColors; extern uint32_t g_frameDelay; -// Watch out for MAXBASEPALS in the engine before increasing this -#define BASEPALCOUNT 7 - extern uint8_t water_pal[768],slime_pal[768],title_pal[768],dre_alms[768],ending_pal[768],*anim_pal; - extern uint8_t *basepaltable[BASEPALCOUNT]; -typedef enum basepal_ { - BASEPAL = 0, - WATERPAL, - SLIMEPAL, - DREALMSPAL, - TITLEPAL, - ENDINGPAL, - ANIMPAL -} basepal_t; - extern user_defs ud; int32_t A_CheckInventorySprite(spritetype *s); @@ -313,12 +310,11 @@ static inline int32_t G_GetTeamPalette(int32_t team) int32_t G_GetVersionFromWebsite(char *buffer); #endif -#if defined(RENDERTYPEWIN) && defined(USE_OPENGL) +#ifdef RENDERTYPEWIN +void app_crashhandler(void); +#ifdef USE_OPENGL extern char forcegl; #endif - -#if defined(RENDERTYPEWIN) -void app_crashhandler(void); #endif #if KRANDDEBUG diff --git a/polymer-perf/eduke32/source/gamedef.c b/polymer-perf/eduke32/source/gamedef.c index 8774b15b7..0fa23a0e0 100644 --- a/polymer-perf/eduke32/source/gamedef.c +++ b/polymer-perf/eduke32/source/gamedef.c @@ -1084,38 +1084,37 @@ void C_InitHashes() #define IFELSE_MAGIC 31337 static int32_t g_ifElseAborted; -static int32_t C_SetScriptSize(int32_t size) +static int32_t C_SetScriptSize(int32_t newsize) { intptr_t oscriptPtr = (unsigned)(g_scriptPtr-script); intptr_t ocaseScriptPtr = (unsigned)(g_caseScriptPtr-script); intptr_t oparsingEventPtr = (unsigned)(g_parsingEventPtr-script); intptr_t oparsingActorPtr = (unsigned)(g_parsingActorPtr-script); - char *scriptptrs; intptr_t *newscript; intptr_t i, j; int32_t osize = g_scriptSize; + char *scriptptrs; char *newbitptr; for (i=MAXSECTORS-1; i>=0; i--) - { if (labelcode[i] && labeltype[i] != LABEL_DEFINE) { - labelcode[i] -= (intptr_t)&script[0]; + j = (intptr_t)labelcode[i]-(intptr_t)&script[0]; + labelcode[i] = (intptr_t)j; } - } - scriptptrs = Bcalloc(1,g_scriptSize * sizeof(uint8_t)); + scriptptrs = Bcalloc(1, g_scriptSize * sizeof(uint8_t)); + for (i=g_scriptSize-1; i>=0; i--) { - if (bitptr[i>>3]&(BITPTR_POINTER<<(i&7)) && !((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_scriptSize]))) - { - g_numCompilerErrors++; - initprintf("Internal compiler error at %"PRIdPTR" (0x%"PRIxPTR")\n",i,i); - } -// if (bitptr[i] == 0 && ((intptr_t)script[i] >= (intptr_t)(&script[0]) && (intptr_t)script[i] < (intptr_t)(&script[g_scriptSize]))) -// initprintf("oh no!\n"); if (bitptr[i>>3]&(BITPTR_POINTER<<(i&7))) { + if ((intptr_t)script[i] < (intptr_t)&script[0] || (intptr_t)script[i] >= (intptr_t)&script[g_scriptSize]) + { + g_numCompilerErrors++; + initprintf("Internal compiler error at %"PRIdPTR" (0x%"PRIxPTR")\n",i,i); + } + scriptptrs[i] = 1; script[i] -= (intptr_t)&script[0]; } @@ -1129,6 +1128,7 @@ static int32_t C_SetScriptSize(int32_t size) j = (intptr_t)actorscrptr[i]-(intptr_t)&script[0]; actorscrptr[i] = (intptr_t *)j; } + if (actorLoadEventScrptr[i]) { j = (intptr_t)actorLoadEventScrptr[i]-(intptr_t)&script[0]; @@ -1143,14 +1143,10 @@ static int32_t C_SetScriptSize(int32_t size) apScriptGameEvent[i] = (intptr_t *)j; } - //initprintf("offset: %d\n",(unsigned)(g_scriptPtr-script)); - g_scriptSize = size; - initprintf("Resizing code buffer to %d*%d bytes\n",g_scriptSize, (int32_t)sizeof(intptr_t)); + initprintf("Resizing code buffer to %d*%d bytes\n",newsize, (int32_t)sizeof(intptr_t)); - newscript = (intptr_t *)Brealloc(script, g_scriptSize * sizeof(intptr_t)); - -// bitptr = (char *)Brealloc(bitptr, g_scriptSize * sizeof(uint8_t)); - newbitptr = Bcalloc(1,(((size+7)>>3)+1) * sizeof(uint8_t)); + newscript = (intptr_t *)Brealloc(script, newsize * sizeof(intptr_t)); + newbitptr = Bcalloc(1,(((newsize+7)>>3)+1) * sizeof(uint8_t)); if (newscript == NULL || newbitptr == NULL) { @@ -1161,14 +1157,13 @@ static int32_t C_SetScriptSize(int32_t size) return 1; } - if (size >= osize) + if (newsize >= osize) { - Bmemset(&newscript[osize],0,(size-osize) * sizeof(intptr_t)); -// Bmemset(&bitptr[osize],0,size-osize); + Bmemset(&newscript[0]+osize,0,(newsize-osize) * sizeof(uint8_t)); Bmemcpy(newbitptr,bitptr,sizeof(uint8_t) *((osize+7)>>3)); } else - Bmemcpy(newbitptr,bitptr,sizeof(uint8_t) *((size+7)>>3)); + Bmemcpy(newbitptr,bitptr,sizeof(uint8_t) *((newsize+7)>>3)); Bfree(bitptr); bitptr = newbitptr; @@ -1178,10 +1173,8 @@ static int32_t C_SetScriptSize(int32_t size) script = newscript; } + g_scriptSize = newsize; g_scriptPtr = (intptr_t *)(script+oscriptPtr); -// initprintf("script: %d, bitptr: %d\n",script,bitptr); - - //initprintf("offset: %d\n",(unsigned)(g_scriptPtr-script)); if (g_caseScriptPtr) g_caseScriptPtr = (intptr_t *)(script+ocaseScriptPtr); @@ -1196,28 +1189,17 @@ static int32_t C_SetScriptSize(int32_t size) { if (labelcode[i] && labeltype[i] != LABEL_DEFINE) { - labelcode[i] += (intptr_t)&script[0]; + j = (intptr_t)labelcode[i]+(intptr_t)&script[0]; + labelcode[i] = j; } } - if (size >= osize) - { - for (i=g_scriptSize-(size-osize)-1; i>=0; i--) - if (scriptptrs[i]) - { - j = (intptr_t)script[i]+(intptr_t)&script[0]; - script[i] = j; - } - } - else - { - for (i=g_scriptSize-1; i>=0; i--) - if (scriptptrs[i]) - { - j = (intptr_t)script[i]+(intptr_t)&script[0]; - script[i] = j; - } - } + for (i=(((newsize>=osize)?osize:newsize))-1; i>=0; i--) + if (scriptptrs[i]) + { + j = (intptr_t)script[i]+(intptr_t)&script[0]; + script[i] = j; + } for (i=MAXTILES-1; i>=0; i--) { @@ -1539,6 +1521,9 @@ static int32_t C_GetKeyword(void) C_SkipComments(); + if (*textptr == '\0') // EOF + return 0; + temptextptr = textptr; while (isaltok(*temptextptr) == 0) @@ -2788,6 +2773,8 @@ static int32_t C_ParseCommand(void) return 0; case CON_ACTOR: + case CON_USERACTOR: + case CON_EVENTLOADACTOR: if (g_processingState || g_parsingActorPtr) { C_ReportError(ERROR_FOUNDWITHIN); @@ -2798,6 +2785,12 @@ static int32_t C_ParseCommand(void) g_scriptPtr--; g_parsingActorPtr = g_scriptPtr; + if (tw == CON_USERACTOR) + { + C_GetNextValue(LABEL_DEFINE); + g_scriptPtr--; + } + C_SkipComments(); j = 0; while (isaltok(*(textptr+j))) @@ -2806,11 +2799,35 @@ static int32_t C_ParseCommand(void) j++; } g_szCurrentBlockName[j] = 0; + + if (tw == CON_USERACTOR) + { + j = *g_scriptPtr; + + if (j > 2) + { + C_ReportError(-1); + initprintf("%s:%d: warning: invalid useractor type.\n",g_szScriptFileName,g_lineNumber); + g_numCompilerWarnings++; + j = 0; + } + } + C_GetNextValue(LABEL_DEFINE); - // Bsprintf(g_szCurrentBlockName,"%s",label+(g_numLabels<<6)); g_scriptPtr--; + + if (tw == CON_EVENTLOADACTOR) + { + actorLoadEventScrptr[*g_scriptPtr] = g_parsingActorPtr; + g_checkingIfElse = 0; + return 0; + } + actorscrptr[*g_scriptPtr] = g_parsingActorPtr; + if (tw == CON_USERACTOR) + ActorType[*g_scriptPtr] = j; + for (j=0; j<4; j++) { bitptr[(g_parsingActorPtr+j-script)>>3] &= ~(1<<((g_parsingActorPtr+j-script)&7)); @@ -2913,127 +2930,6 @@ static int32_t C_ParseCommand(void) return 0; - case CON_EVENTLOADACTOR: - if (g_processingState || g_parsingActorPtr) - { - C_ReportError(ERROR_FOUNDWITHIN); - g_numCompilerErrors++; - } - - g_numBraces = 0; - g_scriptPtr--; - g_parsingActorPtr = g_scriptPtr; - - C_SkipComments(); - j = 0; - while (isaltok(*(textptr+j))) - { - g_szCurrentBlockName[j] = textptr[j]; - j++; - } - g_szCurrentBlockName[j] = 0; - C_GetNextValue(LABEL_DEFINE); - g_scriptPtr--; - actorLoadEventScrptr[*g_scriptPtr] = g_parsingActorPtr; - - g_checkingIfElse = 0; - return 0; - - case CON_USERACTOR: - if (g_processingState || g_parsingActorPtr) - { - C_ReportError(ERROR_FOUNDWITHIN); - g_numCompilerErrors++; - } - - g_numBraces = 0; - g_scriptPtr--; - g_parsingActorPtr = g_scriptPtr; - - C_GetNextValue(LABEL_DEFINE); - g_scriptPtr--; - - C_SkipComments(); - j = 0; - while (isaltok(*(textptr+j))) - { - g_szCurrentBlockName[j] = textptr[j]; - j++; - } - g_szCurrentBlockName[j] = 0; - - j = *g_scriptPtr; - - if (j > 2) - { - C_ReportError(-1); - initprintf("%s:%d: warning: invalid useractor type.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; - j = 0; - } - - C_GetNextValue(LABEL_DEFINE); - g_scriptPtr--; - actorscrptr[*g_scriptPtr] = g_parsingActorPtr; - ActorType[*g_scriptPtr] = j; - - for (j=0; j<4; j++) - { - bitptr[(g_scriptPtr-script)>>3] &= ~(BITPTR_POINTER<<((g_scriptPtr-script)&7)); - *(g_parsingActorPtr+j) = 0; - if (j == 3) - { - j = 0; - while (C_GetKeyword() == -1) - { - C_GetNextValue(LABEL_DEFINE); - g_scriptPtr--; - j |= *g_scriptPtr; - } - bitptr[(g_scriptPtr-script)>>3] &= ~(BITPTR_POINTER<<((g_scriptPtr-script)&7)); - *g_scriptPtr = j; - g_scriptPtr++; - break; - } - else - { - if (C_GetKeyword() >= 0) - { - for (i=4-j; i; i--) - { - bitptr[(g_scriptPtr-script)>>3] &= ~(BITPTR_POINTER<<((g_scriptPtr-script)&7)); - *(g_scriptPtr++) = 0; - } - break; - } - switch (j) - { - case 0: - C_GetNextValue(LABEL_DEFINE); - break; - case 1: - C_GetNextValue(LABEL_ACTION); - break; - case 2: - if ((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(g_scriptPtr-1) != 0) && (*(g_scriptPtr-1) != 1)) - { - C_ReportError(-1); - bitptr[(g_scriptPtr-script-1)>>3] &= ~(1<<((g_scriptPtr-script-1)&7)); - *(g_scriptPtr-1) = 0; - initprintf("%s:%d: warning: expected a move, found a constant.\n",g_szScriptFileName,g_lineNumber); - g_numCompilerWarnings++; - } - break; - } - if (*(g_scriptPtr-1) >= (intptr_t)&script[0] && *(g_scriptPtr-1) < (intptr_t)&script[g_scriptSize]) - bitptr[(g_parsingActorPtr+j-script)>>3] |= (BITPTR_POINTER<<((g_parsingActorPtr+j-script)&7)); - else bitptr[(g_parsingActorPtr+j-script)>>3] &= ~(1<<((g_parsingActorPtr+j-script)&7)); - *(g_parsingActorPtr+j) = *(g_scriptPtr-1); - } - } - g_checkingIfElse = 0; - return 0; - case CON_INSERTSPRITEQ: /* if (!C_CheckEventSync(g_currentEvent)) @@ -5375,7 +5271,7 @@ repeatcase: int32_t fullscreen = ud.config.ScreenMode; int32_t xdim = ud.config.ScreenWidth, ydim = ud.config.ScreenHeight, bpp = ud.config.ScreenBPP; int32_t usemouse = ud.config.UseMouse, usejoy = ud.config.UseJoystick; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL int32_t glrm = glrendmode; #endif @@ -5403,7 +5299,7 @@ repeatcase: } Bstrcpy(temp,tempbuf); - CONFIG_WriteSetup(); + CONFIG_WriteSetup(1); if (g_modDir[0] != '/') Bsprintf(setupfilename,"%s/",g_modDir); else setupfilename[0] = 0; @@ -5419,7 +5315,7 @@ repeatcase: ud.config.ScreenBPP = bpp; ud.config.UseMouse = usemouse; ud.config.UseJoystick = usejoy; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL glrendmode = glrm; #endif @@ -5552,8 +5448,8 @@ repeatcase: tempbuf[i] = '\0'; - if (MapInfo[j *MAXLEVELS+k].name == NULL) - MapInfo[j *MAXLEVELS+k].name = Bcalloc(Bstrlen(tempbuf)+1,sizeof(uint8_t)); + if (MapInfo[j*MAXLEVELS+k].name == NULL) + MapInfo[j*MAXLEVELS+k].name = Bcalloc(Bstrlen(tempbuf)+1,sizeof(uint8_t)); else if ((Bstrlen(tempbuf)+1) > sizeof(MapInfo[j*MAXLEVELS+k].name)) MapInfo[j *MAXLEVELS+k].name = Brealloc(MapInfo[j*MAXLEVELS+k].name,(Bstrlen(tempbuf)+1)); @@ -5582,6 +5478,7 @@ repeatcase: if (ScriptQuotes[k] == NULL) ScriptQuotes[k] = Bcalloc(MAXQUOTELEN,sizeof(uint8_t)); + if (!ScriptQuotes[k]) { ScriptQuotes[k] = NULL; diff --git a/polymer-perf/eduke32/source/gameexec.c b/polymer-perf/eduke32/source/gameexec.c index 9d0fd5534..a5742c7b8 100644 --- a/polymer-perf/eduke32/source/gameexec.c +++ b/polymer-perf/eduke32/source/gameexec.c @@ -83,56 +83,47 @@ void VM_ScriptInfo(void) void VM_OnEvent(register int32_t iEventID, register int32_t iActor, register int32_t iPlayer, register int32_t lDist) { - if (iEventID < 0 || iEventID >= MAXGAMEEVENTS || apScriptGameEvent[iEventID] == 0) + if (!apScriptGameEvent[iEventID]) return; { intptr_t *oinsptr=insptr; vmstate_t vm_backup; vmstate_t tempvm = { iActor, iPlayer, lDist, &actor[iActor].t_data[0], - &sprite[iActor], 0 - }; + &sprite[iActor], 0 }; + + insptr = apScriptGameEvent[iEventID]; Bmemcpy(&vm_backup, &vm, sizeof(vmstate_t)); Bmemcpy(&vm, &tempvm, sizeof(vmstate_t)); - insptr = apScriptGameEvent[iEventID]; - VM_Execute(0); if (vm.g_flags & VM_KILL) { // if player was set to squish, first stop that... - if (vm.g_p >= 0) - { - if (g_player[vm.g_p].ps->actorsqu == vm.g_i) - g_player[vm.g_p].ps->actorsqu = -1; - } + if (vm.g_p >= 0 && g_player[vm.g_p].ps->actorsqu == vm.g_i) + g_player[vm.g_p].ps->actorsqu = -1; + deletesprite(vm.g_i); } Bmemcpy(&vm, &vm_backup, sizeof(vmstate_t)); - insptr=oinsptr; + insptr = oinsptr; } } -static int32_t VM_CheckSquished(void) +static inline int32_t VM_CheckSquished(void) { sectortype *sc = §or[vm.g_sp->sectnum]; - int32_t squishme = 0; - if ((vm.g_sp->picnum == APLAYER && ud.clipping) || sc->lotag == 23) + if ((vm.g_sp->picnum == APLAYER && ud.clipping) || sc->lotag == 23 || + (vm.g_sp->pal == 1 ? + !(sc->floorz - sc->ceilingz < (32<<8) && (sc->lotag&32768) == 0) : + !(sc->floorz - sc->ceilingz < (12<<8)))) return 0; - squishme = (sc->floorz - sc->ceilingz < (12<<8)); // && (sc->lotag&32768) == 0; - - if (vm.g_sp->pal == 1) - squishme = (sc->floorz - sc->ceilingz < (32<<8) && (sc->lotag&32768) == 0); - - if (!squishme) - return 0; - - P_DoQuote(10, g_player[vm.g_p].ps); + P_DoQuote(QUOTE_SQUISHED, g_player[vm.g_p].ps); if (A_CheckEnemySprite(vm.g_sp)) vm.g_sp->xvel = 0; @@ -152,13 +143,12 @@ GAMEEXEC_STATIC GAMEEXEC_INLINE void P_ForceAngle(DukePlayer_t *p) p->horiz += 64; p->return_to_center = 9; - p->look_ang = n>>1; - p->rotscrnang = n>>1; + p->look_ang = p->rotscrnang = n>>1; } GAMEEXEC_STATIC int32_t A_Dodge(spritetype *s) { - int32_t bx,by,bxvect,byvect,d,i; + int32_t bx,by,bxvect,byvect,i; int32_t mx = s->x, my = s->y; int32_t mxvect = sintable[(s->ang+512)&2047]; int32_t myvect = sintable[s->ang&2047]; @@ -168,7 +158,7 @@ GAMEEXEC_STATIC int32_t A_Dodge(spritetype *s) for (i=headspritestat[STAT_PROJECTILE]; i>=0; i=nextspritestat[i]) //weapons list { - if (OW == i/* || SECT != s->sectnum*/) + if (OW == i) continue; bx = SX-mx; @@ -176,16 +166,14 @@ GAMEEXEC_STATIC int32_t A_Dodge(spritetype *s) bxvect = sintable[(SA+512)&2047]; byvect = sintable[SA&2047]; - if (mxvect *bx + myvect *by >= 0) - if (bxvect*bx + byvect*by < 0) + if ((mxvect * bx) + (myvect * by) >= 0 && (bxvect * bx) + (byvect * by) < 0) + { + if (klabs((bxvect * by) - (byvect * bx)) < 65536<<6) { - d = bxvect*by - byvect*bx; - if (klabs(d) < 65536*64) - { - s->ang -= 512+(krand()&1024); - return 1; - } + s->ang -= 512+(krand()&1024); + return 1; } + } } return 0; } @@ -384,7 +372,7 @@ GAMEEXEC_STATIC GAMEEXEC_INLINE void VM_AlterAng(int32_t a) intptr_t *moveptr; int32_t ticselapsed = (vm.g_t[0])&31; - if ((moveptr = (intptr_t *)vm.g_t[1]) < &script[0] || moveptr > (&script[0]+g_scriptSize)) + if ((moveptr = (intptr_t *)vm.g_t[1]) < &script[0] || moveptr > &script[g_scriptSize]) { vm.g_t[1] = 0; OSD_Printf(OSD_ERROR "bad moveptr for actor %d (%d)!\n", vm.g_i, vm.g_sp->picnum); @@ -508,8 +496,8 @@ GAMEEXEC_STATIC void VM_Move(void) if (a&face_player_smart && !deadflag) { - int32_t newx = g_player[vm.g_p].ps->pos.x+(g_player[vm.g_p].ps->posvel.x/768); - int32_t newy = g_player[vm.g_p].ps->pos.y+(g_player[vm.g_p].ps->posvel.y/768); + int32_t newx = g_player[vm.g_p].ps->pos.x+(g_player[vm.g_p].ps->vel.x/768); + int32_t newy = g_player[vm.g_p].ps->pos.y+(g_player[vm.g_p].ps->vel.y/768); goalang = getangle(newx-vm.g_sp->x,newy-vm.g_sp->y); angdif = G_GetAngleDelta(vm.g_sp->ang,goalang)>>2; @@ -518,18 +506,16 @@ GAMEEXEC_STATIC void VM_Move(void) vm.g_sp->ang += angdif; } - if ((moveptr = (intptr_t *)vm.g_t[1]) >= &script[0] && moveptr <= (&script[0]+g_scriptSize)) - { - if (a&geth) vm.g_sp->xvel += ((*moveptr)-vm.g_sp->xvel)>>1; - if (a&getv) vm.g_sp->zvel += ((*(moveptr+1)<<4)-vm.g_sp->zvel)>>1; - } - else + if ((moveptr = (intptr_t *)vm.g_t[1]) < &script[0] || moveptr > &script[g_scriptSize]) { vm.g_t[1] = 0; OSD_Printf(OSD_ERROR "bad moveptr for actor %d (%d)!\n", vm.g_i, vm.g_sp->picnum); return; } + if (a&geth) vm.g_sp->xvel += ((*moveptr)-vm.g_sp->xvel)>>1; + if (a&getv) vm.g_sp->zvel += ((*(moveptr+1)<<4)-vm.g_sp->zvel)>>1; + if (a&dodgebullet && !deadflag) A_Dodge(vm.g_sp); @@ -613,13 +599,13 @@ GAMEEXEC_STATIC void VM_Move(void) if (vm.g_x < 512) { - g_player[vm.g_p].ps->posvel.x = 0; - g_player[vm.g_p].ps->posvel.y = 0; + g_player[vm.g_p].ps->vel.x = 0; + g_player[vm.g_p].ps->vel.y = 0; } else { - g_player[vm.g_p].ps->posvel.x = mulscale(g_player[vm.g_p].ps->posvel.x,g_player[vm.g_p].ps->runspeed-0x2000,16); - g_player[vm.g_p].ps->posvel.y = mulscale(g_player[vm.g_p].ps->posvel.y,g_player[vm.g_p].ps->runspeed-0x2000,16); + g_player[vm.g_p].ps->vel.x = mulscale(g_player[vm.g_p].ps->vel.x,g_player[vm.g_p].ps->runspeed-0x2000,16); + g_player[vm.g_p].ps->vel.y = mulscale(g_player[vm.g_p].ps->vel.y,g_player[vm.g_p].ps->runspeed-0x2000,16); } } else if (vm.g_sp->picnum != DRONE && vm.g_sp->picnum != SHARK && vm.g_sp->picnum != COMMANDER) @@ -881,15 +867,13 @@ skip_check: continue; case CON_IFPDISTL: - insptr++; - VM_DoConditional(vm.g_x < *insptr); + VM_DoConditional(vm.g_x < *(++insptr)); if (vm.g_x > MAXSLEEPDIST && actor[vm.g_i].timetosleep == 0) actor[vm.g_i].timetosleep = SLEEPTIME; continue; case CON_IFPDISTG: - insptr++; - VM_DoConditional(vm.g_x > *insptr); + VM_DoConditional(vm.g_x > *(++insptr)); if (vm.g_x > MAXSLEEPDIST && actor[vm.g_i].timetosleep == 0) actor[vm.g_i].timetosleep = SLEEPTIME; continue; @@ -957,7 +941,7 @@ skip_check: case CON_MIKESND: insptr++; - if ((vm.g_sp->yvel<0 || vm.g_sp->yvel>=MAXSOUNDS)) + if (((unsigned)vm.g_sp->yvel >= MAXSOUNDS)) { OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],vm.g_sp->yvel); insptr++; @@ -1009,8 +993,7 @@ skip_check: continue; case CON_SOUNDONCE: - insptr++; - if ((*insptr<0 || *insptr>=MAXSOUNDS)) + if (((unsigned)*(++insptr) >= MAXSOUNDS)) { OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr++); continue; @@ -1024,7 +1007,7 @@ skip_check: { int32_t i = Gv_GetVarX(*insptr++), j = Gv_GetVarX(*insptr++); - if ((j<0 || j>=MAXSOUNDS)) + if (((unsigned)j >= MAXSOUNDS)) { OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],j); insptr++; @@ -1036,8 +1019,7 @@ skip_check: continue; case CON_IFSOUND: - insptr++; - if ((*insptr<0 || *insptr>=MAXSOUNDS)) + if (((unsigned)*(++insptr) >= MAXSOUNDS)) { OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr); insptr++; @@ -1048,8 +1030,7 @@ skip_check: continue; case CON_STOPSOUND: - insptr++; - if ((*insptr<0 || *insptr>=MAXSOUNDS)) + if (((unsigned)*(++insptr) >= MAXSOUNDS)) { OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr); insptr++; @@ -1078,8 +1059,7 @@ skip_check: } case CON_GLOBALSOUND: - insptr++; - if ((*insptr<0 || *insptr>=MAXSOUNDS)) + if (((unsigned)*(++insptr) >= MAXSOUNDS)) { OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr); insptr++; @@ -1091,8 +1071,7 @@ skip_check: continue; case CON_SOUND: - insptr++; - if ((*insptr<0 || *insptr>=MAXSOUNDS)) + if ((unsigned)*(++insptr) >= MAXSOUNDS) { OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr); insptr++; @@ -1154,7 +1133,7 @@ skip_check: { j = vm.g_sp->sectnum; pushmove((vec3_t *)vm.g_sp,(int16_t *)&j,128L,(4L<<8),(4L<<8),CLIPMASK0); - if (j != vm.g_sp->sectnum && j >= 0 && j < MAXSECTORS) + if ((unsigned)j < MAXSECTORS) changespritesect(vm.g_i,j); A_PlaySound(THUD,vm.g_i); } @@ -1176,8 +1155,10 @@ skip_check: // fix for flying/jumping monsters getting stuck in water { intptr_t *moveptr = (intptr_t *)vm.g_t[1]; - if (vm.g_sp->hitag & jumptoplayer || (actorscrptr[vm.g_sp->picnum] && - moveptr >= &script[0] && moveptr <= (&script[0]+g_scriptSize) && *(moveptr+1))) + if (vm.g_sp->hitag & jumptoplayer || + (actorscrptr[vm.g_sp->picnum] && + (unsigned int)(moveptr - &script[0]) <= (unsigned int)(&script[g_scriptSize] - &script[0]) && + *(moveptr+1))) { // OSD_Printf("%d\n",*(moveptr+1)); break; @@ -1205,8 +1186,7 @@ skip_check: insptr++; return 1; case CON_ADDAMMO: - insptr++; - if ((*insptr<0 || *insptr>=MAX_WEAPONS)) + if (((unsigned)*(++insptr) >= MAX_WEAPONS)) { OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr); insptr += 2; break; @@ -1263,8 +1243,7 @@ skip_check: continue; case CON_ADDWEAPON: - insptr++; - if ((*insptr<0 ||*insptr>=MAX_WEAPONS)) + if (((unsigned)*(++insptr) >= MAX_WEAPONS)) { OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr); insptr += 2; @@ -1437,7 +1416,7 @@ skip_check: { case CON_ACTIVATEBYSECTOR: if ((var1<0 || var1>=numsectors)) {OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],var1); break;} - activatebysector(var1, var2); + G_ActivateBySector(var1, var2); break; case CON_OPERATESECTORS: if ((var1<0 || var1>=numsectors)) {OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],var1); break;} @@ -1451,7 +1430,7 @@ skip_check: setaspect(var1, var2); break; case CON_SSP: - if ((var1<0 || var1>=MAXSPRITES)) { OSD_Printf(CON_ERROR "Invalid sprite %d\n",g_errorLineNum,keyw[g_tw],var1); break;} + if ((unsigned)var1 >= MAXSPRITES) { OSD_Printf(CON_ERROR "Invalid sprite %d\n",g_errorLineNum,keyw[g_tw],var1); break;} A_SetSprite(var1, var2); break; } @@ -1463,9 +1442,9 @@ skip_check: { int32_t lVar1 = Gv_GetVarX(*insptr++), lVar2 = Gv_GetVarX(*insptr++), res; - if ((lVar1<0 || lVar1>=MAXSPRITES || lVar2<0 || lVar2>=MAXSPRITES)) + if ((unsigned)lVar1 >= MAXSPRITES || (unsigned)lVar2 >= MAXSPRITES) { - OSD_Printf(CON_ERROR "Invalid sprite %d\n",g_errorLineNum,keyw[g_tw],lVar1<0||lVar1>=MAXSPRITES?lVar1:lVar2); + OSD_Printf(CON_ERROR "Invalid sprite %d\n",g_errorLineNum,keyw[g_tw],(unsigned)lVar1 >= MAXSPRITES ? lVar1 : lVar2); res=0; } else res=cansee(sprite[lVar1].x,sprite[lVar1].y,sprite[lVar1].z,sprite[lVar1].sectnum, @@ -1522,7 +1501,7 @@ skip_check: { int32_t i=*insptr++; int32_t j=Gv_GetVarX(*insptr++); - if ((j < 0 || j > MAXSTATUS)) + if ((unsigned)j > MAXSTATUS) { OSD_Printf(CON_ERROR "invalid status list %d\n",g_errorLineNum,keyw[g_tw],j); continue; @@ -1536,7 +1515,7 @@ skip_check: { int32_t i=*insptr++; int32_t j=Gv_GetVarX(*insptr++); - if ((j < 0 || j >= MAXSPRITES)) + if ((unsigned)j >= MAXSPRITES) { OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j); continue; @@ -1550,7 +1529,7 @@ skip_check: { int32_t i=*insptr++; int32_t j=Gv_GetVarX(*insptr++); - if ((j < 0 || j >= MAXSPRITES)) + if ((unsigned)j >= MAXSPRITES) { OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j); continue; @@ -1564,7 +1543,7 @@ skip_check: { int32_t i=*insptr++; int32_t j=Gv_GetVarX(*insptr++); - if ((j < 0 || j > numsectors)) + if ((unsigned)j >= (unsigned)numsectors) { OSD_Printf(CON_ERROR "invalid sector %d\n",g_errorLineNum,keyw[g_tw],j); continue; @@ -1578,7 +1557,7 @@ skip_check: { int32_t i=*insptr++; int32_t j=Gv_GetVarX(*insptr++); - if ((j < 0 || j >= MAXSPRITES)) + if ((unsigned)j >= MAXSPRITES) { OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j); continue; @@ -1592,7 +1571,7 @@ skip_check: { int32_t i=*insptr++; int32_t j=Gv_GetVarX(*insptr++); - if ((j < 0 || j >= MAXSPRITES)) + if ((unsigned)j >= MAXSPRITES) { OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j); continue; @@ -1719,7 +1698,7 @@ skip_check: Bstrcpy(ScriptQuotes[i],g_player[vm.g_p].user_name); break; case STR_VERSION: - Bsprintf(tempbuf,HEAD2 " %s",s_buildDate); + Bsprintf(tempbuf,HEAD2 " %s",s_buildRev); Bstrcpy(ScriptQuotes[i],tempbuf); break; case STR_GAMETYPE: @@ -1745,12 +1724,12 @@ skip_check: Bstrcpy(ScriptQuotes[i],ScriptQuotes[j]); break; case CON_CHANGESPRITESECT: - if ((i<0 || i>=MAXSPRITES)) + if ((unsigned)i >= MAXSPRITES) { OSD_Printf(CON_ERROR "Invalid sprite %d\n",g_errorLineNum,keyw[g_tw],i); break; } - if ((j<0 || j>=numsectors)) + if ((unsigned)j >= (unsigned)numsectors) { OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],j); break; @@ -1771,12 +1750,12 @@ nullquote: int32_t i = Gv_GetVarX(*insptr++); int32_t j = Gv_GetVarX(*insptr++); - if ((i<0 || i>=MAXSPRITES)) + if ((unsigned)i >= MAXSPRITES) { OSD_Printf(CON_ERROR "Invalid sprite: %d\n",g_errorLineNum,keyw[g_tw],i); continue; } - if ((j<0 || j>=MAXSTATUS)) + if ((unsigned)j >= MAXSTATUS) { OSD_Printf(CON_ERROR "Invalid statnum: %d\n",g_errorLineNum,keyw[g_tw],j); continue; @@ -1974,7 +1953,7 @@ nullquote: { int32_t distvar = *insptr++, xvar = Gv_GetVarX(*insptr++), yvar = Gv_GetVarX(*insptr++); - if ((xvar < 0 || yvar < 0 || xvar >= MAXSPRITES || yvar >= MAXSPRITES)) + if ((unsigned)xvar >= MAXSPRITES || (unsigned)yvar >= MAXSPRITES) { OSD_Printf(CON_ERROR "invalid sprite\n",g_errorLineNum,keyw[g_tw]); continue; @@ -1989,7 +1968,7 @@ nullquote: { int32_t distvar = *insptr++, xvar = Gv_GetVarX(*insptr++), yvar = Gv_GetVarX(*insptr++); - if ((xvar < 0 || yvar < 0 || xvar >= MAXSPRITES || yvar >= MAXSPRITES)) + if ((unsigned)xvar >= MAXSPRITES || (unsigned)yvar >= MAXSPRITES) { OSD_Printf(CON_ERROR "invalid sprite\n",g_errorLineNum,keyw[g_tw]); continue; @@ -2055,7 +2034,7 @@ nullquote: { int32_t lIn=Gv_GetVarX(*insptr++); int32_t j; - if ((vm.g_sp->sectnum < 0 || vm.g_sp->sectnum >= numsectors)) + if ((unsigned)vm.g_sp->sectnum >= (unsigned)numsectors) { OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],vm.g_sp->sectnum); continue; @@ -2085,7 +2064,7 @@ nullquote: { int32_t j; - if ((vm.g_sp->sectnum < 0 || vm.g_sp->sectnum >= numsectors)) + if ((unsigned)vm.g_sp->sectnum >= (unsigned)numsectors) { OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],vm.g_sp->sectnum); insptr++; @@ -2125,7 +2104,7 @@ nullquote: actor[vm.g_i].shootzvel = 1; } - if ((vm.g_sp->sectnum < 0 || vm.g_sp->sectnum >= numsectors)) + if ((unsigned)vm.g_sp->sectnum >= (unsigned)numsectors) { OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],vm.g_sp->sectnum); insptr++; @@ -2148,7 +2127,7 @@ nullquote: { int32_t j=Gv_GetVarX(*insptr++); - if ((vm.g_sp->sectnum < 0 || vm.g_sp->sectnum >= numsectors)) + if ((unsigned)vm.g_sp->sectnum >= (unsigned)numsectors) { OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],vm.g_sp->sectnum); actor[vm.g_i].shootzvel=0; @@ -2174,7 +2153,7 @@ nullquote: { int32_t j=Gv_GetVarX(*insptr++); - if ((vm.g_sp->sectnum < 0 || vm.g_sp->sectnum >= numsectors)) + if ((unsigned)vm.g_sp->sectnum >= (unsigned)numsectors) { OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],vm.g_sp->sectnum); actor[vm.g_i].shootzvel=0; @@ -2276,7 +2255,7 @@ nullquote: int32_t x2=scale(Gv_GetVarX(*insptr++),xdim,320); int32_t y2=scale(Gv_GetVarX(*insptr++),ydim,200); int32_t smoothratio = min(max((totalclock - ototalclock) * (65536 / 4),0),65536); -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL int32_t j; #endif @@ -2296,7 +2275,7 @@ nullquote: continue; } -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL j = glprojectionhacks; glprojectionhacks = 0; #endif @@ -2358,7 +2337,7 @@ nullquote: drawmasks(); G_RestoreInterpolations(); G_UpdateScreenArea(); -#if defined(USE_OPENGL) && defined(POLYMOST) +#ifdef USE_OPENGL glprojectionhacks = j; #endif continue; @@ -2708,7 +2687,7 @@ nullquote: if (tw == CON_SETSPRITE) { - if ((spritenum < 0 || spritenum >= MAXSPRITES)) + if ((unsigned)spritenum >= MAXSPRITES) { OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],spritenum); continue; @@ -2720,7 +2699,7 @@ nullquote: { int32_t cliptype = Gv_GetVarX(*insptr++); - if ((spritenum < 0 && spritenum >= MAXSPRITES)) + if ((unsigned)spritenum >= MAXSPRITES) { OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],spritenum); insptr++; @@ -2770,7 +2749,7 @@ nullquote: case CON_SPAWN: insptr++; - if (vm.g_sp->sectnum >= 0 && vm.g_sp->sectnum < MAXSECTORS) + if ((unsigned)vm.g_sp->sectnum < MAXSECTORS) A_Spawn(vm.g_i,*insptr); insptr++; continue; @@ -2806,7 +2785,7 @@ nullquote: int32_t dnum = *insptr++; int32_t s, l, j; - if (vm.g_sp->sectnum >= 0 && vm.g_sp->sectnum < MAXSECTORS) + if ((unsigned)vm.g_sp->sectnum < MAXSECTORS) for (j=(*insptr)-1; j>=0; j--) { if (vm.g_sp->picnum == BLIMP && dnum == SCRAP1) @@ -2922,13 +2901,19 @@ nullquote: if (g_netServer) { + int32_t jj = 0; + P_ResetPlayer(vm.g_p); - packbuf[0] = PACKET_PLAYER_SPAWN; - packbuf[1] = vm.g_p; - packbuf[2] = 0; + packbuf[jj++] = PACKET_PLAYER_SPAWN; + packbuf[jj++] = vm.g_p; - enet_host_broadcast(g_netServer, CHAN_GAMESTATE , enet_packet_create(packbuf, 3, ENET_PACKET_FLAG_RELIABLE)); + Bmemcpy(&packbuf[jj], &g_player[vm.g_p].ps->pos.x, sizeof(vec3_t) * 2); + jj += sizeof(vec3_t) * 2; + + packbuf[jj++] = 0; + + enet_host_broadcast(g_netServer, CHAN_GAMESTATE , enet_packet_create(packbuf, jj, ENET_PACKET_FLAG_RELIABLE)); } } P_UpdateScreenPal(g_player[vm.g_p].ps); @@ -3048,7 +3033,7 @@ nullquote: if ((l&8) && g_player[vm.g_p].ps->on_ground && TEST_SYNC_KEY(g_player[vm.g_p].sync->bits, SK_CROUCH)) j = 1; else if ((l&16) && g_player[vm.g_p].ps->jumping_counter == 0 && !g_player[vm.g_p].ps->on_ground && - g_player[vm.g_p].ps->posvel.z > 2048) + g_player[vm.g_p].ps->vel.z > 2048) j = 1; else if ((l&32) && g_player[vm.g_p].ps->jumping_counter > 348) j = 1; @@ -3138,7 +3123,7 @@ nullquote: insptr++; { int32_t j = Gv_GetVarX(*insptr++); - if ((j < 0 || j >= MAXVOLUMES*MAXLEVELS)) + if ((unsigned)j >= MAXVOLUMES*MAXLEVELS) { OSD_Printf(CON_ERROR "Invalid map number: %d\n",g_errorLineNum,keyw[g_tw],j); continue; @@ -3183,7 +3168,8 @@ nullquote: insptr++; if (sector[vm.g_sp->sectnum].lotag == 0) { - neartag(vm.g_sp->x,vm.g_sp->y,vm.g_sp->z-(32<<8),vm.g_sp->sectnum,vm.g_sp->ang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,768L,1); + neartag(vm.g_sp->x,vm.g_sp->y,vm.g_sp->z-(32<<8),vm.g_sp->sectnum,vm.g_sp->ang, + &neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,768L,5); if (neartagsector >= 0 && isanearoperator(sector[neartagsector].lotag)) if ((sector[neartagsector].lotag&0xff) == 23 || sector[neartagsector].floorz == sector[neartagsector].ceilingz) if ((sector[neartagsector].lotag&16384) == 0) @@ -3399,7 +3385,7 @@ nullquote: intptr_t *oinsptr = insptr++; int32_t index = Gv_GetVarX(*insptr++); insptr = oinsptr; - if (index < 0 || index >= MAXSPRITES-1) + if ((unsigned)index >= MAXSPRITES-1) { OSD_Printf(CON_ERROR "invalid array index\n",g_errorLineNum,keyw[g_tw]); Gv_GetVarX(*insptr++); @@ -3781,7 +3767,7 @@ nullquote: int32_t lSprite=Gv_GetVarX(*insptr++), lVar1=*insptr++; int32_t lVar2=*insptr++; - if ((lSprite < 0 || lSprite >= MAXSPRITES)) + if ((unsigned)lSprite >= MAXSPRITES) { OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],lSprite); if (lVar1 == MAXGAMEVARS || lVar1 & ((MAXGAMEVARS<<2)|(MAXGAMEVARS<<3))) insptr++; @@ -3811,7 +3797,7 @@ nullquote: { int32_t lVar1=*insptr++, lVar2=*insptr++; - if ((iPlayer < 0 || iPlayer >= playerswhenstarted)) + if ((unsigned)iPlayer >= (unsigned)playerswhenstarted) { OSD_Printf(CON_ERROR "invalid player ID %d\n",g_errorLineNum,keyw[g_tw],iPlayer); if (lVar1 == MAXGAMEVARS || lVar1 & ((MAXGAMEVARS<<2)|(MAXGAMEVARS<<3))) insptr++; @@ -3907,7 +3893,7 @@ nullquote: insptr++; - if ((j < 0 || j >= playerswhenstarted)) + if ((unsigned)j >= (unsigned)playerswhenstarted) { OSD_Printf(CON_ERROR "Invalid player ID %d\n",g_errorLineNum,keyw[g_tw],j); continue; @@ -4044,10 +4030,10 @@ nullquote: insptr++; { int32_t j=*insptr++; - int32_t index = Gv_GetVar(*insptr++, vm.g_i, vm.g_p); + int32_t index = Gv_GetVarX(*insptr++); int32_t j1=*insptr++; - int32_t index1 = Gv_GetVar(*insptr++, vm.g_i, vm.g_p); - int32_t value = Gv_GetVar(*insptr++, vm.g_i, vm.g_p); + int32_t index1 = Gv_GetVarX(*insptr++); + int32_t value = Gv_GetVarX(*insptr++); if (index > aGameArrays[j].size || index1 > aGameArrays[j1].size) continue; if ((index+value)>aGameArrays[j].size) value=aGameArrays[j].size-index; @@ -4638,7 +4624,7 @@ nullquote: continue; } - if ((vm.g_p < 0 || vm.g_p >= MAXPLAYERS)) + if ((unsigned)vm.g_p >= MAXPLAYERS) { OSD_Printf(CON_ERROR "bad player for quote %d: (%d)\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr,vm.g_p); insptr++; @@ -4788,7 +4774,7 @@ void A_LoadActor(int32_t iActor) vm.g_flags &= ~(VM_RETURN|VM_KILL|VM_NOEXECUTE); - if (vm.g_sp->sectnum < 0 || vm.g_sp->sectnum >= MAXSECTORS) + if ((unsigned)vm.g_sp->sectnum >= MAXSECTORS) { // if(A_CheckEnemySprite(vm.g_sp)) // g_player[vm.g_p].ps->actors_killed++; @@ -4821,7 +4807,7 @@ void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist) insptr = 4 + (actorscrptr[vm.g_sp->picnum]); - if (vm.g_sp->sectnum < 0 || vm.g_sp->sectnum >= MAXSECTORS) + if ((unsigned)vm.g_sp->sectnum >= MAXSECTORS) { if (A_CheckEnemySprite(vm.g_sp)) g_player[vm.g_p].ps->actors_killed++; @@ -4832,8 +4818,7 @@ void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist) /* Qbix: Changed variables to be aware of the sizeof *insptr * (whether it is int32_t vs intptr_t), Although it is specifically cast to intptr_t* * which might be corrected if the code is converted to use offsets */ - - if (vm.g_t[4] > (intptr_t)&script[0] && vm.g_t[4] < (intptr_t)&script[g_scriptSize]) + if ((unsigned)(vm.g_t[4]-(intptr_t)&script[0]) <= (unsigned)((intptr_t)&script[g_scriptSize]-(intptr_t)&script[0])) { vm.g_sp->lotag += TICSPERFRAME; @@ -4853,8 +4838,9 @@ void A_Execute(int32_t iActor,int32_t iPlayer,int32_t lDist) if (vm.g_flags & VM_KILL) { // if player was set to squish, first stop that... - if (g_player[vm.g_p].ps->actorsqu == vm.g_i) + if (vm.g_p >= 0 && g_player[vm.g_p].ps->actorsqu == vm.g_i) g_player[vm.g_p].ps->actorsqu = -1; + deletesprite(vm.g_i); return; } @@ -5195,7 +5181,7 @@ void G_RestoreMapState(mapstate_t *save) Net_ResetPrediction(); - clearfifo(); + G_ClearFIFO(); G_ResetTimers(); } } diff --git a/polymer-perf/eduke32/source/gamestructures.c b/polymer-perf/eduke32/source/gamestructures.c index 99e611fef..dc7aab420 100644 --- a/polymer-perf/eduke32/source/gamestructures.c +++ b/polymer-perf/eduke32/source/gamestructures.c @@ -42,7 +42,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t } if (iSet) - lValue=Gv_GetVar(lVar2, vm.g_i, vm.g_p); + lValue=Gv_GetVarX(lVar2); switch (lLabelID) { @@ -52,7 +52,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.god = lValue; return; } - Gv_SetVar(lVar2, ud.god, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.god); return; case USERDEFS_WARP_ON: @@ -61,7 +61,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.warp_on = lValue; return; } - Gv_SetVar(lVar2, ud.warp_on, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.warp_on); return; case USERDEFS_CASHMAN: @@ -70,7 +70,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.cashman = lValue; return; } - Gv_SetVar(lVar2, ud.cashman, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.cashman); return; case USERDEFS_EOG: @@ -79,7 +79,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.eog = lValue; return; } - Gv_SetVar(lVar2, ud.eog, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.eog); return; case USERDEFS_SHOWALLMAP: @@ -88,7 +88,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.showallmap = lValue; return; } - Gv_SetVar(lVar2, ud.showallmap, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.showallmap); return; case USERDEFS_SHOW_HELP: @@ -97,7 +97,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.show_help = lValue; return; } - Gv_SetVar(lVar2, ud.show_help, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.show_help); return; case USERDEFS_SCROLLMODE: @@ -106,7 +106,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.scrollmode = lValue; return; } - Gv_SetVar(lVar2, ud.scrollmode, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.scrollmode); return; case USERDEFS_CLIPPING: @@ -115,7 +115,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.clipping = lValue; return; } - Gv_SetVar(lVar2, ud.clipping, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.clipping); return; // case USERDEFS_USER_NAME: @@ -124,7 +124,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t // ud.user_name[MAXPLAYERS][32] = lValue; // return; // } - // Gv_SetVar(lVar2, ud.user_name[MAXPLAYERS][32], vm.g_i, vm.g_p); + // Gv_SetVarX(lVar2, ud.user_name[MAXPLAYERS][32]); // return; // case USERDEFS_RIDECULE: @@ -133,7 +133,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t // ud.ridecule = lValue; // return; // } - // Gv_SetVar(lVar2, ud.ridecule, vm.g_i, vm.g_p); + // Gv_SetVarX(lVar2, ud.ridecule); // return; // case USERDEFS_SAVEGAME: @@ -142,7 +142,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t // ud.savegame = lValue; // return; // } - // Gv_SetVar(lVar2, ud.savegame, vm.g_i, vm.g_p); + // Gv_SetVarX(lVar2, ud.savegame); // return; // case USERDEFS_PWLOCKOUT: @@ -151,7 +151,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t // ud.pwlockout = lValue; // return; // } - // Gv_SetVar(lVar2, ud.pwlockout, vm.g_i, vm.g_p); + // Gv_SetVarX(lVar2, ud.pwlockout); // return; // case USERDEFS_RTSNAME: @@ -160,7 +160,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t // ud.rtsname = lValue; // return; // } - // Gv_SetVar(lVar2, ud.rtsname, vm.g_i, vm.g_p); + // Gv_SetVarX(lVar2, ud.rtsname); // return; case USERDEFS_OVERHEAD_ON: @@ -169,7 +169,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.overhead_on = lValue; return; } - Gv_SetVar(lVar2, ud.overhead_on, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.overhead_on); return; case USERDEFS_LAST_OVERHEAD: @@ -178,7 +178,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.last_overhead = lValue; return; } - Gv_SetVar(lVar2, ud.last_overhead, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.last_overhead); return; case USERDEFS_SHOWWEAPONS: @@ -187,7 +187,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.showweapons = lValue; return; } - Gv_SetVar(lVar2, ud.showweapons, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.showweapons); return; case USERDEFS_PAUSE_ON: @@ -196,7 +196,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.pause_on = lValue; return; } - Gv_SetVar(lVar2, ud.pause_on, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.pause_on); return; case USERDEFS_FROM_BONUS: @@ -205,7 +205,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.from_bonus = lValue; return; } - Gv_SetVar(lVar2, ud.from_bonus, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.from_bonus); return; case USERDEFS_CAMERASPRITE: @@ -214,7 +214,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.camerasprite = lValue; return; } - Gv_SetVar(lVar2, ud.camerasprite, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.camerasprite); return; case USERDEFS_LAST_CAMSPRITE: @@ -223,7 +223,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.last_camsprite = lValue; return; } - Gv_SetVar(lVar2, ud.last_camsprite, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.last_camsprite); return; case USERDEFS_LAST_LEVEL: @@ -232,7 +232,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.last_level = lValue; return; } - Gv_SetVar(lVar2, ud.last_level, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.last_level); return; case USERDEFS_SECRETLEVEL: @@ -241,7 +241,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.secretlevel = lValue; return; } - Gv_SetVar(lVar2, ud.secretlevel, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.secretlevel); return; case USERDEFS_CONST_VISIBILITY: @@ -250,7 +250,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.const_visibility = lValue; return; } - Gv_SetVar(lVar2, ud.const_visibility, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.const_visibility); return; case USERDEFS_UW_FRAMERATE: @@ -259,7 +259,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.uw_framerate = lValue; return; } - Gv_SetVar(lVar2, ud.uw_framerate, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.uw_framerate); return; case USERDEFS_CAMERA_TIME: @@ -268,7 +268,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.camera_time = lValue; return; } - Gv_SetVar(lVar2, ud.camera_time, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.camera_time); return; case USERDEFS_FOLFVEL: @@ -277,7 +277,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.folfvel = lValue; return; } - Gv_SetVar(lVar2, ud.folfvel, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.folfvel); return; case USERDEFS_FOLAVEL: @@ -286,7 +286,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.folavel = lValue; return; } - Gv_SetVar(lVar2, ud.folavel, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.folavel); return; case USERDEFS_FOLX: @@ -295,7 +295,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.folx = lValue; return; } - Gv_SetVar(lVar2, ud.folx, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.folx); return; case USERDEFS_FOLY: @@ -304,7 +304,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.foly = lValue; return; } - Gv_SetVar(lVar2, ud.foly, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.foly); return; case USERDEFS_FOLA: @@ -313,7 +313,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.fola = lValue; return; } - Gv_SetVar(lVar2, ud.fola, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.fola); return; case USERDEFS_RECCNT: @@ -322,7 +322,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.reccnt = lValue; return; } - Gv_SetVar(lVar2, ud.reccnt, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.reccnt); return; case USERDEFS_ENTERED_NAME: @@ -331,7 +331,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.entered_name = lValue; return; } - Gv_SetVar(lVar2, ud.entered_name, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.entered_name); return; case USERDEFS_SCREEN_TILTING: @@ -340,7 +340,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.screen_tilting = lValue; return; } - Gv_SetVar(lVar2, ud.screen_tilting, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.screen_tilting); return; case USERDEFS_SHADOWS: @@ -349,7 +349,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.shadows = lValue; return; } - Gv_SetVar(lVar2, ud.shadows, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.shadows); return; case USERDEFS_FTA_ON: @@ -358,7 +358,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.fta_on = lValue; return; } - Gv_SetVar(lVar2, ud.fta_on, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.fta_on); return; case USERDEFS_EXECUTIONS: @@ -367,7 +367,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.executions = lValue; return; } - Gv_SetVar(lVar2, ud.executions, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.executions); return; case USERDEFS_AUTO_RUN: @@ -376,7 +376,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.auto_run = lValue; return; } - Gv_SetVar(lVar2, ud.auto_run, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.auto_run); return; case USERDEFS_COORDS: @@ -385,7 +385,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.coords = lValue; return; } - Gv_SetVar(lVar2, ud.coords, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.coords); return; case USERDEFS_TICKRATE: @@ -394,7 +394,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.tickrate = lValue; return; } - Gv_SetVar(lVar2, ud.tickrate, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.tickrate); return; case USERDEFS_M_COOP: @@ -403,7 +403,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.m_coop = lValue; return; } - Gv_SetVar(lVar2, ud.m_coop, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.m_coop); return; case USERDEFS_COOP: @@ -412,7 +412,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.coop = lValue; return; } - Gv_SetVar(lVar2, ud.coop, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.coop); return; case USERDEFS_SCREEN_SIZE: @@ -425,7 +425,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t } return; } - Gv_SetVar(lVar2, ud.screen_size, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.screen_size); return; case USERDEFS_LOCKOUT: @@ -434,7 +434,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.lockout = lValue; return; } - Gv_SetVar(lVar2, ud.lockout, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.lockout); return; case USERDEFS_CROSSHAIR: @@ -443,7 +443,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.crosshair = lValue; return; } - Gv_SetVar(lVar2, ud.crosshair, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.crosshair); return; // case USERDEFS_WCHOICE: @@ -452,7 +452,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t // ud.wchoice = lValue; // return; // } - // Gv_SetVar(lVar2, ud.wchoice, vm.g_i, vm.g_p); + // Gv_SetVarX(lVar2, ud.wchoice); // return; case USERDEFS_PLAYERAI: @@ -461,7 +461,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.playerai = lValue; return; } - Gv_SetVar(lVar2, ud.playerai, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.playerai); return; case USERDEFS_RESPAWN_MONSTERS: @@ -470,7 +470,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.respawn_monsters = lValue; return; } - Gv_SetVar(lVar2, ud.respawn_monsters, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.respawn_monsters); return; case USERDEFS_RESPAWN_ITEMS: @@ -479,7 +479,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.respawn_items = lValue; return; } - Gv_SetVar(lVar2, ud.respawn_items, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.respawn_items); return; case USERDEFS_RESPAWN_INVENTORY: @@ -488,7 +488,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.respawn_inventory = lValue; return; } - Gv_SetVar(lVar2, ud.respawn_inventory, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.respawn_inventory); return; case USERDEFS_RECSTAT: @@ -497,7 +497,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.recstat = lValue; return; } - Gv_SetVar(lVar2, ud.recstat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.recstat); return; case USERDEFS_MONSTERS_OFF: @@ -506,7 +506,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.monsters_off = lValue; return; } - Gv_SetVar(lVar2, ud.monsters_off, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.monsters_off); return; case USERDEFS_BRIGHTNESS: @@ -515,7 +515,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.brightness = lValue; return; } - Gv_SetVar(lVar2, ud.brightness, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.brightness); return; case USERDEFS_M_RESPAWN_ITEMS: @@ -524,7 +524,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.m_respawn_items = lValue; return; } - Gv_SetVar(lVar2, ud.m_respawn_items, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.m_respawn_items); return; case USERDEFS_M_RESPAWN_MONSTERS: @@ -533,7 +533,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.m_respawn_monsters = lValue; return; } - Gv_SetVar(lVar2, ud.m_respawn_monsters, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.m_respawn_monsters); return; case USERDEFS_M_RESPAWN_INVENTORY: @@ -542,7 +542,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.m_respawn_inventory = lValue; return; } - Gv_SetVar(lVar2, ud.m_respawn_inventory, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.m_respawn_inventory); return; case USERDEFS_M_RECSTAT: @@ -551,7 +551,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.m_recstat = lValue; return; } - Gv_SetVar(lVar2, ud.m_recstat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.m_recstat); return; case USERDEFS_M_MONSTERS_OFF: @@ -560,7 +560,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.m_monsters_off = lValue; return; } - Gv_SetVar(lVar2, ud.m_monsters_off, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.m_monsters_off); return; case USERDEFS_DETAIL: @@ -569,7 +569,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.detail = lValue; return; } - Gv_SetVar(lVar2, ud.detail, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.detail); return; case USERDEFS_M_FFIRE: @@ -578,7 +578,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.m_ffire = lValue; return; } - Gv_SetVar(lVar2, ud.m_ffire, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.m_ffire); return; case USERDEFS_FFIRE: @@ -587,7 +587,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.ffire = lValue; return; } - Gv_SetVar(lVar2, ud.ffire, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.ffire); return; case USERDEFS_M_PLAYER_SKILL: @@ -596,7 +596,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.m_player_skill = lValue; return; } - Gv_SetVar(lVar2, ud.m_player_skill, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.m_player_skill); return; case USERDEFS_M_LEVEL_NUMBER: @@ -605,7 +605,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.m_level_number = lValue; return; } - Gv_SetVar(lVar2, ud.m_level_number, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.m_level_number); return; case USERDEFS_M_VOLUME_NUMBER: @@ -614,7 +614,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.m_volume_number = lValue; return; } - Gv_SetVar(lVar2, ud.m_volume_number, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.m_volume_number); return; case USERDEFS_MULTIMODE: @@ -623,7 +623,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.multimode = lValue; return; } - Gv_SetVar(lVar2, ud.multimode, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.multimode); return; case USERDEFS_PLAYER_SKILL: @@ -632,7 +632,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.player_skill = lValue; return; } - Gv_SetVar(lVar2, ud.player_skill, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.player_skill); return; case USERDEFS_LEVEL_NUMBER: @@ -641,7 +641,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.level_number = lValue; return; } - Gv_SetVar(lVar2, ud.level_number, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.level_number); return; case USERDEFS_VOLUME_NUMBER: @@ -650,7 +650,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.volume_number = lValue; return; } - Gv_SetVar(lVar2, ud.volume_number, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.volume_number); return; case USERDEFS_M_MARKER: @@ -659,7 +659,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.m_marker = lValue; return; } - Gv_SetVar(lVar2, ud.m_marker, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.m_marker); return; case USERDEFS_MARKER: @@ -668,7 +668,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.marker = lValue; return; } - Gv_SetVar(lVar2, ud.marker, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.marker); return; case USERDEFS_MOUSEFLIP: @@ -677,7 +677,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.mouseflip = lValue; return; } - Gv_SetVar(lVar2, ud.mouseflip, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.mouseflip); return; case USERDEFS_STATUSBARSCALE: @@ -686,7 +686,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.statusbarscale = lValue; return; } - Gv_SetVar(lVar2, ud.statusbarscale, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.statusbarscale); return; case USERDEFS_DRAWWEAPON: @@ -695,7 +695,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.drawweapon = lValue; return; } - Gv_SetVar(lVar2, ud.drawweapon, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.drawweapon); return; case USERDEFS_MOUSEAIMING: @@ -704,7 +704,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.mouseaiming = lValue; return; } - Gv_SetVar(lVar2, ud.mouseaiming, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.mouseaiming); return; case USERDEFS_WEAPONSWITCH: @@ -713,7 +713,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.weaponswitch = lValue; return; } - Gv_SetVar(lVar2, ud.weaponswitch, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.weaponswitch); return; case USERDEFS_DEMOCAMS: @@ -722,7 +722,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.democams = lValue; return; } - Gv_SetVar(lVar2, ud.democams, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.democams); return; case USERDEFS_COLOR: @@ -731,7 +731,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.color = lValue; return; } - Gv_SetVar(lVar2, ud.color, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.color); return; case USERDEFS_MSGDISPTIME: @@ -740,7 +740,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.msgdisptime = lValue; return; } - Gv_SetVar(lVar2, ud.msgdisptime, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.msgdisptime); return; case USERDEFS_STATUSBARMODE: @@ -749,7 +749,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.statusbarmode = lValue; return; } - Gv_SetVar(lVar2, ud.statusbarmode, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.statusbarmode); return; case USERDEFS_M_NOEXITS: @@ -758,7 +758,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.m_noexits = lValue; return; } - Gv_SetVar(lVar2, ud.m_noexits, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.m_noexits); return; case USERDEFS_NOEXITS: @@ -767,7 +767,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.noexits = lValue; return; } - Gv_SetVar(lVar2, ud.noexits, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.noexits); return; case USERDEFS_AUTOVOTE: @@ -776,7 +776,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.autovote = lValue; return; } - Gv_SetVar(lVar2, ud.autovote, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.autovote); return; case USERDEFS_AUTOMSG: @@ -785,7 +785,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.automsg = lValue; return; } - Gv_SetVar(lVar2, ud.automsg, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.automsg); return; case USERDEFS_IDPLAYERS: @@ -794,7 +794,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.idplayers = lValue; return; } - Gv_SetVar(lVar2, ud.idplayers, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.idplayers); return; case USERDEFS_TEAM: @@ -803,7 +803,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.team = lValue; return; } - Gv_SetVar(lVar2, ud.team, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.team); return; case USERDEFS_VIEWBOB: @@ -812,7 +812,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.viewbob = lValue; return; } - Gv_SetVar(lVar2, ud.viewbob, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.viewbob); return; case USERDEFS_WEAPONSWAY: @@ -821,7 +821,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.weaponsway = lValue; return; } - Gv_SetVar(lVar2, ud.weaponsway, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.weaponsway); return; case USERDEFS_ANGLEINTERPOLATION: @@ -830,7 +830,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.angleinterpolation = lValue; return; } - Gv_SetVar(lVar2, ud.angleinterpolation, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.angleinterpolation); return; case USERDEFS_OBITUARIES: @@ -839,7 +839,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.obituaries = lValue; return; } - Gv_SetVar(lVar2, ud.obituaries, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.obituaries); return; case USERDEFS_LEVELSTATS: @@ -848,7 +848,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.levelstats = lValue; return; } - Gv_SetVar(lVar2, ud.levelstats, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.levelstats); return; case USERDEFS_CROSSHAIRSCALE: @@ -857,7 +857,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.crosshairscale = lValue; return; } - Gv_SetVar(lVar2, ud.crosshairscale, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.crosshairscale); return; case USERDEFS_ALTHUD: @@ -866,7 +866,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.althud = lValue; return; } - Gv_SetVar(lVar2, ud.althud, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.althud); return; case USERDEFS_DISPLAY_BONUS_SCREEN: @@ -875,7 +875,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.display_bonus_screen = lValue; return; } - Gv_SetVar(lVar2, ud.display_bonus_screen, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.display_bonus_screen); return; case USERDEFS_SHOW_LEVEL_TEXT: @@ -884,7 +884,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.show_level_text = lValue; return; } - Gv_SetVar(lVar2, ud.show_level_text, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.show_level_text); return; case USERDEFS_WEAPONSCALE: @@ -893,7 +893,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.weaponscale = lValue; return; } - Gv_SetVar(lVar2, ud.weaponscale, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.weaponscale); return; case USERDEFS_TEXTSCALE: @@ -902,7 +902,7 @@ static void __fastcall VM_AccessUserdef(int32_t iSet, int32_t lLabelID, int32_t ud.textscale = lValue; return; } - Gv_SetVar(lVar2, ud.textscale, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ud.textscale); return; default: @@ -915,9 +915,9 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in int32_t lValue=0,proj=vm.g_i; if (lVar1 != g_iThisActorID) - proj=Gv_GetVar(lVar1, vm.g_i, vm.g_p); + proj=Gv_GetVarX(lVar1); - if ((proj < 0 || proj >= MAXSPRITES) /* && g_scriptSanityChecks */) + if ((unsigned)proj >= MAXSPRITES) { // OSD_Printf("VM_AccessActiveProjectile(): invalid projectile (%d)\n",proj); OSD_Printf(CON_ERROR "tried to %s %s on invalid target projectile (%d) %d %d from %s\n",g_errorLineNum,keyw[g_tw], @@ -928,7 +928,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in } if (iSet) - lValue=Gv_GetVar(lVar2, vm.g_i, vm.g_p); + lValue=Gv_GetVarX(lVar2); switch (lLabelID) { @@ -938,7 +938,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].workslike=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].workslike, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].workslike); return; case PROJ_SPAWNS: @@ -947,7 +947,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].spawns=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].spawns, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].spawns); return; case PROJ_SXREPEAT: @@ -956,7 +956,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].sxrepeat=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].sxrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].sxrepeat); return; case PROJ_SYREPEAT: @@ -965,7 +965,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].syrepeat=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].syrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].syrepeat); return; case PROJ_SOUND: @@ -974,7 +974,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].sound=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].sound, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].sound); return; case PROJ_ISOUND: @@ -983,7 +983,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].isound=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].isound, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].isound); return; case PROJ_VEL: @@ -992,7 +992,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].vel=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].vel, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].vel); return; case PROJ_EXTRA: @@ -1001,7 +1001,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].extra=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].extra, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].extra); return; case PROJ_DECAL: @@ -1010,7 +1010,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].decal=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].decal, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].decal); return; case PROJ_TRAIL: @@ -1019,7 +1019,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].trail=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].trail, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].trail); return; case PROJ_TXREPEAT: @@ -1028,7 +1028,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].txrepeat=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].txrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].txrepeat); return; case PROJ_TYREPEAT: @@ -1037,7 +1037,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].tyrepeat=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].tyrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].tyrepeat); return; case PROJ_TOFFSET: @@ -1046,7 +1046,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].toffset=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].toffset, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].toffset); return; case PROJ_TNUM: @@ -1055,7 +1055,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].tnum=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].tnum, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].tnum); return; case PROJ_DROP: @@ -1064,7 +1064,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].drop=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].drop, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].drop); return; case PROJ_CSTAT: @@ -1073,7 +1073,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].cstat=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].cstat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].cstat); return; case PROJ_CLIPDIST: @@ -1082,7 +1082,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].clipdist=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].clipdist, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].clipdist); return; case PROJ_SHADE: @@ -1091,7 +1091,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].shade=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].shade, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].shade); return; case PROJ_XREPEAT: @@ -1100,7 +1100,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].xrepeat=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].xrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].xrepeat); return; case PROJ_YREPEAT: @@ -1109,7 +1109,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].yrepeat=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].yrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].yrepeat); return; case PROJ_PAL: @@ -1118,7 +1118,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].pal=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].pal, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].pal); return; case PROJ_EXTRA_RAND: @@ -1127,7 +1127,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].extra_rand=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].extra_rand, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].extra_rand); return; case PROJ_HITRADIUS: @@ -1136,7 +1136,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].hitradius=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].hitradius, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].hitradius); return; case PROJ_VEL_MULT: @@ -1145,7 +1145,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].velmult=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].velmult, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].velmult); return; case PROJ_OFFSET: @@ -1154,7 +1154,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].offset=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].offset, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].offset); return; case PROJ_BOUNCES: @@ -1163,7 +1163,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].bounces=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].bounces, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].bounces); return; case PROJ_BSOUND: @@ -1172,7 +1172,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].bsound=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].bsound, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].bsound); return; case PROJ_RANGE: @@ -1181,7 +1181,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].range=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].range, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].range); return; case PROJ_FLASH_COLOR: @@ -1190,7 +1190,7 @@ static void __fastcall VM_AccessActiveProjectile(int32_t iSet, int32_t lVar1, in SpriteProjectile[proj].flashcolor=lValue; return; } - Gv_SetVar(lVar2, SpriteProjectile[proj].flashcolor, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, SpriteProjectile[proj].flashcolor); return; default: @@ -1203,7 +1203,7 @@ static void __fastcall VM_GetPlayer(register int32_t lVar1, register int32_t lLa register int32_t iPlayer=vm.g_p; if (lVar1 != g_iThisActorID) - iPlayer=Gv_GetVar(lVar1, vm.g_i, vm.g_p); + iPlayer=Gv_GetVarX(lVar1); if ((iPlayer<0 || iPlayer >= playerswhenstarted) /* && g_scriptSanityChecks */) goto badplayer; @@ -1214,302 +1214,302 @@ static void __fastcall VM_GetPlayer(register int32_t lVar1, register int32_t lLa switch (lLabelID) { case PLAYER_ZOOM: - Gv_SetVar(lVar2, g_player[iPlayer].ps->zoom, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->zoom); return; case PLAYER_EXITX: - Gv_SetVar(lVar2, g_player[iPlayer].ps->exitx, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->exitx); return; case PLAYER_EXITY: - Gv_SetVar(lVar2, g_player[iPlayer].ps->exity, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->exity); return; case PLAYER_LOOGIEX: - Gv_SetVar(lVar2, g_player[iPlayer].ps->loogiex[lParm2], vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->loogiex[lParm2]); return; case PLAYER_LOOGIEY: - Gv_SetVar(lVar2, g_player[iPlayer].ps->loogiey[lParm2], vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->loogiey[lParm2]); return; case PLAYER_NUMLOOGS: - Gv_SetVar(lVar2, g_player[iPlayer].ps->numloogs, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->numloogs); return; case PLAYER_LOOGCNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->loogcnt, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->loogcnt); return; case PLAYER_POSX: - Gv_SetVar(lVar2, g_player[iPlayer].ps->pos.x, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->pos.x); return; case PLAYER_POSY: - Gv_SetVar(lVar2, g_player[iPlayer].ps->pos.y, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->pos.y); return; case PLAYER_POSZ: - Gv_SetVar(lVar2, g_player[iPlayer].ps->pos.z, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->pos.z); return; case PLAYER_HORIZ: - Gv_SetVar(lVar2, g_player[iPlayer].ps->horiz, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->horiz); return; case PLAYER_OHORIZ: - Gv_SetVar(lVar2, g_player[iPlayer].ps->ohoriz, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->ohoriz); return; case PLAYER_OHORIZOFF: - Gv_SetVar(lVar2, g_player[iPlayer].ps->ohorizoff, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->ohorizoff); return; case PLAYER_INVDISPTIME: - Gv_SetVar(lVar2, g_player[iPlayer].ps->invdisptime, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->invdisptime); return; case PLAYER_BOBPOSX: - Gv_SetVar(lVar2, g_player[iPlayer].ps->bobposx, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->bobposx); return; case PLAYER_BOBPOSY: - Gv_SetVar(lVar2, g_player[iPlayer].ps->bobposy, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->bobposy); return; case PLAYER_OPOSX: - Gv_SetVar(lVar2, g_player[iPlayer].ps->opos.x, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->opos.x); return; case PLAYER_OPOSY: - Gv_SetVar(lVar2, g_player[iPlayer].ps->opos.y, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->opos.y); return; case PLAYER_OPOSZ: - Gv_SetVar(lVar2, g_player[iPlayer].ps->opos.z, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->opos.z); return; case PLAYER_PYOFF: - Gv_SetVar(lVar2, g_player[iPlayer].ps->pyoff, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->pyoff); return; case PLAYER_OPYOFF: - Gv_SetVar(lVar2, g_player[iPlayer].ps->opyoff, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->opyoff); return; case PLAYER_POSXV: - Gv_SetVar(lVar2, g_player[iPlayer].ps->posvel.x, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->vel.x); return; case PLAYER_POSYV: - Gv_SetVar(lVar2, g_player[iPlayer].ps->posvel.y, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->vel.y); return; case PLAYER_POSZV: - Gv_SetVar(lVar2, g_player[iPlayer].ps->posvel.z, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->vel.z); return; case PLAYER_LAST_PISSED_TIME: - Gv_SetVar(lVar2, g_player[iPlayer].ps->last_pissed_time, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->last_pissed_time); return; case PLAYER_TRUEFZ: - Gv_SetVar(lVar2, g_player[iPlayer].ps->truefz, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->truefz); return; case PLAYER_TRUECZ: - Gv_SetVar(lVar2, g_player[iPlayer].ps->truecz, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->truecz); return; case PLAYER_PLAYER_PAR: - Gv_SetVar(lVar2, g_player[iPlayer].ps->player_par, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->player_par); return; case PLAYER_VISIBILITY: - Gv_SetVar(lVar2, g_player[iPlayer].ps->visibility, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->visibility); return; case PLAYER_BOBCOUNTER: - Gv_SetVar(lVar2, g_player[iPlayer].ps->bobcounter, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->bobcounter); return; case PLAYER_WEAPON_SWAY: - Gv_SetVar(lVar2, g_player[iPlayer].ps->weapon_sway, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->weapon_sway); return; case PLAYER_PALS_TIME: - Gv_SetVar(lVar2, g_player[iPlayer].ps->pals.f, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->pals.f); return; case PLAYER_RANDOMFLAMEX: - Gv_SetVar(lVar2, g_player[iPlayer].ps->randomflamex, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->randomflamex); return; case PLAYER_CRACK_TIME: - Gv_SetVar(lVar2, g_player[iPlayer].ps->crack_time, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->crack_time); return; case PLAYER_AIM_MODE: - Gv_SetVar(lVar2, g_player[iPlayer].ps->aim_mode, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->aim_mode); return; case PLAYER_ANG: - Gv_SetVar(lVar2, g_player[iPlayer].ps->ang, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->ang); return; case PLAYER_OANG: - Gv_SetVar(lVar2, g_player[iPlayer].ps->oang, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->oang); return; case PLAYER_ANGVEL: - Gv_SetVar(lVar2, g_player[iPlayer].ps->angvel, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->angvel); return; case PLAYER_CURSECTNUM: - Gv_SetVar(lVar2, g_player[iPlayer].ps->cursectnum, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->cursectnum); return; case PLAYER_LOOK_ANG: - Gv_SetVar(lVar2, g_player[iPlayer].ps->look_ang, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->look_ang); return; case PLAYER_LAST_EXTRA: - Gv_SetVar(lVar2, g_player[iPlayer].ps->last_extra, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->last_extra); return; case PLAYER_SUBWEAPON: - Gv_SetVar(lVar2, g_player[iPlayer].ps->subweapon, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->subweapon); return; case PLAYER_AMMO_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->ammo_amount[lParm2], vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->ammo_amount[lParm2]); return; case PLAYER_WACKEDBYACTOR: - Gv_SetVar(lVar2, g_player[iPlayer].ps->wackedbyactor, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->wackedbyactor); return; case PLAYER_FRAG: - Gv_SetVar(lVar2, g_player[iPlayer].ps->frag, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->frag); return; case PLAYER_FRAGGEDSELF: - Gv_SetVar(lVar2, g_player[iPlayer].ps->fraggedself, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->fraggedself); return; case PLAYER_CURR_WEAPON: - Gv_SetVar(lVar2, g_player[iPlayer].ps->curr_weapon, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->curr_weapon); return; case PLAYER_LAST_WEAPON: - Gv_SetVar(lVar2, g_player[iPlayer].ps->last_weapon, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->last_weapon); return; case PLAYER_TIPINCS: - Gv_SetVar(lVar2, g_player[iPlayer].ps->tipincs, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->tipincs); return; case PLAYER_HORIZOFF: - Gv_SetVar(lVar2, g_player[iPlayer].ps->horizoff, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->horizoff); return; case PLAYER_WANTWEAPONFIRE: - Gv_SetVar(lVar2, g_player[iPlayer].ps->wantweaponfire, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->wantweaponfire); return; case PLAYER_HOLODUKE_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_HOLODUKE], vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->inv_amount[GET_HOLODUKE]); return; case PLAYER_NEWOWNER: - Gv_SetVar(lVar2, g_player[iPlayer].ps->newowner, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->newowner); return; case PLAYER_HURT_DELAY: - Gv_SetVar(lVar2, g_player[iPlayer].ps->hurt_delay, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->hurt_delay); return; case PLAYER_HBOMB_HOLD_DELAY: - Gv_SetVar(lVar2, g_player[iPlayer].ps->hbomb_hold_delay, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->hbomb_hold_delay); return; case PLAYER_JUMPING_COUNTER: - Gv_SetVar(lVar2, g_player[iPlayer].ps->jumping_counter, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->jumping_counter); return; case PLAYER_AIRLEFT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->airleft, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->airleft); return; case PLAYER_KNEE_INCS: - Gv_SetVar(lVar2, g_player[iPlayer].ps->knee_incs, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->knee_incs); return; case PLAYER_ACCESS_INCS: - Gv_SetVar(lVar2, g_player[iPlayer].ps->access_incs, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->access_incs); return; case PLAYER_FTA: - Gv_SetVar(lVar2, g_player[iPlayer].ps->fta, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->fta); return; case PLAYER_FTQ: - Gv_SetVar(lVar2, g_player[iPlayer].ps->ftq, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->ftq); return; case PLAYER_ACCESS_WALLNUM: - Gv_SetVar(lVar2, g_player[iPlayer].ps->access_wallnum, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->access_wallnum); return; case PLAYER_ACCESS_SPRITENUM: - Gv_SetVar(lVar2, g_player[iPlayer].ps->access_spritenum, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->access_spritenum); return; case PLAYER_KICKBACK_PIC: - Gv_SetVar(lVar2, g_player[iPlayer].ps->kickback_pic, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->kickback_pic); return; case PLAYER_GOT_ACCESS: - Gv_SetVar(lVar2, g_player[iPlayer].ps->got_access, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->got_access); return; case PLAYER_WEAPON_ANG: - Gv_SetVar(lVar2, g_player[iPlayer].ps->weapon_ang, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->weapon_ang); return; case PLAYER_FIRSTAID_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_FIRSTAID], vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->inv_amount[GET_FIRSTAID]); return; case PLAYER_SOMETHINGONPLAYER: - Gv_SetVar(lVar2, g_player[iPlayer].ps->somethingonplayer, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->somethingonplayer); return; case PLAYER_ON_CRANE: - Gv_SetVar(lVar2, g_player[iPlayer].ps->on_crane, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->on_crane); return; case PLAYER_I: - Gv_SetVar(lVar2, g_player[iPlayer].ps->i, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->i); return; case PLAYER_ONE_PARALLAX_SECTNUM: - Gv_SetVar(lVar2, g_player[iPlayer].ps->one_parallax_sectnum, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->one_parallax_sectnum); return; case PLAYER_OVER_SHOULDER_ON: - Gv_SetVar(lVar2, g_player[iPlayer].ps->over_shoulder_on, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->over_shoulder_on); return; case PLAYER_RANDOM_CLUB_FRAME: - Gv_SetVar(lVar2, g_player[iPlayer].ps->random_club_frame, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->random_club_frame); return; case PLAYER_FIST_INCS: - Gv_SetVar(lVar2, g_player[iPlayer].ps->fist_incs, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->fist_incs); return; case PLAYER_ONE_EIGHTY_COUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->one_eighty_count, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->one_eighty_count); return; case PLAYER_CHEAT_PHASE: - Gv_SetVar(lVar2, g_player[iPlayer].ps->cheat_phase, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->cheat_phase); return; case PLAYER_DUMMYPLAYERSPRITE: - Gv_SetVar(lVar2, g_player[iPlayer].ps->dummyplayersprite, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->dummyplayersprite); return; case PLAYER_EXTRA_EXTRA8: - Gv_SetVar(lVar2, g_player[iPlayer].ps->extra_extra8, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->extra_extra8); return; case PLAYER_QUICK_KICK: - Gv_SetVar(lVar2, g_player[iPlayer].ps->quick_kick, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->quick_kick); return; case PLAYER_HEAT_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_HEATS], vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->inv_amount[GET_HEATS]); return; case PLAYER_ACTORSQU: - Gv_SetVar(lVar2, g_player[iPlayer].ps->actorsqu, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->actorsqu); return; case PLAYER_TIMEBEFOREEXIT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->timebeforeexit, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->timebeforeexit); return; case PLAYER_CUSTOMEXITSOUND: - Gv_SetVar(lVar2, g_player[iPlayer].ps->customexitsound, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->customexitsound); return; case PLAYER_WEAPRECS: - Gv_SetVar(lVar2, g_player[iPlayer].ps->weaprecs[lParm2], vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->weaprecs[lParm2]); return; case PLAYER_WEAPRECCNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->weapreccnt, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->weapreccnt); return; case PLAYER_INTERFACE_TOGGLE_FLAG: - Gv_SetVar(lVar2, g_player[iPlayer].ps->interface_toggle_flag, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->interface_toggle_flag); return; case PLAYER_ROTSCRNANG: - Gv_SetVar(lVar2, g_player[iPlayer].ps->rotscrnang, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->rotscrnang); return; case PLAYER_DEAD_FLAG: - Gv_SetVar(lVar2, g_player[iPlayer].ps->dead_flag, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->dead_flag); return; case PLAYER_SHOW_EMPTY_WEAPON: - Gv_SetVar(lVar2, g_player[iPlayer].ps->show_empty_weapon, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->show_empty_weapon); return; case PLAYER_SCUBA_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_SCUBA], vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->inv_amount[GET_SCUBA]); return; case PLAYER_JETPACK_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_JETPACK], vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->inv_amount[GET_JETPACK]); return; case PLAYER_STEROIDS_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_STEROIDS], vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->inv_amount[GET_STEROIDS]); return; case PLAYER_SHIELD_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_SHIELD], vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->inv_amount[GET_SHIELD]); return; case PLAYER_HOLODUKE_ON: - Gv_SetVar(lVar2, g_player[iPlayer].ps->holoduke_on, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->holoduke_on); return; case PLAYER_PYCOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->pycount, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->pycount); return; case PLAYER_WEAPON_POS: - Gv_SetVar(lVar2, g_player[iPlayer].ps->weapon_pos, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->weapon_pos); return; case PLAYER_FRAG_PS: - Gv_SetVar(lVar2, g_player[iPlayer].ps->frag_ps, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->frag_ps); return; case PLAYER_TRANSPORTER_HOLD: - Gv_SetVar(lVar2, g_player[iPlayer].ps->transporter_hold, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->transporter_hold); return; case PLAYER_LAST_FULL_WEAPON: - Gv_SetVar(lVar2, g_player[iPlayer].ps->last_full_weapon, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->last_full_weapon); return; case PLAYER_FOOTPRINTSHADE: - Gv_SetVar(lVar2, g_player[iPlayer].ps->footprintshade, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->footprintshade); return; case PLAYER_BOOT_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->inv_amount[GET_BOOTS], vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->inv_amount[GET_BOOTS]); return; case PLAYER_SCREAM_VOICE: - Gv_SetVar(lVar2, g_player[iPlayer].ps->scream_voice, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->scream_voice); return; case PLAYER_GM: - Gv_SetVar(lVar2, g_player[iPlayer].ps->gm, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->gm); return; case PLAYER_ON_WARPING_SECTOR: - Gv_SetVar(lVar2, g_player[iPlayer].ps->on_warping_sector, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->on_warping_sector); return; case PLAYER_FOOTPRINTCOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->footprintcount, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->footprintcount); return; case PLAYER_HBOMB_ON: - Gv_SetVar(lVar2, g_player[iPlayer].ps->hbomb_on, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->hbomb_on); return; case PLAYER_JUMPING_TOGGLE: - Gv_SetVar(lVar2, g_player[iPlayer].ps->jumping_toggle, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->jumping_toggle); return; case PLAYER_RAPID_FIRE_HOLD: - Gv_SetVar(lVar2, g_player[iPlayer].ps->rapid_fire_hold, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->rapid_fire_hold); return; case PLAYER_ON_GROUND: - Gv_SetVar(lVar2, g_player[iPlayer].ps->on_ground, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->on_ground); return; case PLAYER_INVEN_ICON: - Gv_SetVar(lVar2, g_player[iPlayer].ps->inven_icon, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->inven_icon); return; case PLAYER_BUTTONPALETTE: - Gv_SetVar(lVar2, g_player[iPlayer].ps->buttonpalette, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->buttonpalette); return; case PLAYER_JETPACK_ON: - Gv_SetVar(lVar2, g_player[iPlayer].ps->jetpack_on, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->jetpack_on); return; case PLAYER_SPRITEBRIDGE: - Gv_SetVar(lVar2, g_player[iPlayer].ps->spritebridge, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->spritebridge); return; case PLAYER_LASTRANDOMSPOT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->lastrandomspot, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->lastrandomspot); return; case PLAYER_SCUBA_ON: - Gv_SetVar(lVar2, g_player[iPlayer].ps->scuba_on, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->scuba_on); return; case PLAYER_FOOTPRINTPAL: - Gv_SetVar(lVar2, g_player[iPlayer].ps->footprintpal, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->footprintpal); return; case PLAYER_HEAT_ON: - Gv_SetVar(lVar2, g_player[iPlayer].ps->heat_on, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->heat_on); return; case PLAYER_HOLSTER_WEAPON: - Gv_SetVar(lVar2, g_player[iPlayer].ps->holster_weapon, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->holster_weapon); return; case PLAYER_FALLING_COUNTER: - Gv_SetVar(lVar2, g_player[iPlayer].ps->falling_counter, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->falling_counter); return; case PLAYER_GOTWEAPON: - Gv_SetVar(lVar2, (g_player[iPlayer].ps->gotweapon & (1<gotweapon & (1<refresh_inventory, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->refresh_inventory); return; case PLAYER_TOGGLE_KEY_FLAG: - Gv_SetVar(lVar2, g_player[iPlayer].ps->toggle_key_flag, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->toggle_key_flag); return; case PLAYER_KNUCKLE_INCS: - Gv_SetVar(lVar2, g_player[iPlayer].ps->knuckle_incs, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->knuckle_incs); return; case PLAYER_WALKING_SND_TOGGLE: - Gv_SetVar(lVar2, g_player[iPlayer].ps->walking_snd_toggle, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->walking_snd_toggle); return; case PLAYER_PALOOKUP: - Gv_SetVar(lVar2, g_player[iPlayer].ps->palookup, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->palookup); return; case PLAYER_HARD_LANDING: - Gv_SetVar(lVar2, g_player[iPlayer].ps->hard_landing, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->hard_landing); return; case PLAYER_MAX_SECRET_ROOMS: - Gv_SetVar(lVar2, g_player[iPlayer].ps->max_secret_rooms, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->max_secret_rooms); return; case PLAYER_SECRET_ROOMS: - Gv_SetVar(lVar2, g_player[iPlayer].ps->secret_rooms, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->secret_rooms); return; case PLAYER_PALS: switch (lParm2) { case 0: - Gv_SetVar(lVar2, g_player[iPlayer].ps->pals.r, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->pals.r); return; case 1: - Gv_SetVar(lVar2, g_player[iPlayer].ps->pals.g, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->pals.g); return; case 2: - Gv_SetVar(lVar2, g_player[iPlayer].ps->pals.b, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->pals.b); return; } return; case PLAYER_MAX_ACTORS_KILLED: - Gv_SetVar(lVar2, g_player[iPlayer].ps->max_actors_killed, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->max_actors_killed); return; case PLAYER_ACTORS_KILLED: - Gv_SetVar(lVar2, g_player[iPlayer].ps->actors_killed, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->actors_killed); return; case PLAYER_RETURN_TO_CENTER: - Gv_SetVar(lVar2, g_player[iPlayer].ps->return_to_center, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->return_to_center); return; case PLAYER_RUNSPEED: - Gv_SetVar(lVar2, g_player[iPlayer].ps->runspeed, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->runspeed); return; case PLAYER_SBS: - Gv_SetVar(lVar2, g_player[iPlayer].ps->sbs, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->sbs); return; case PLAYER_RELOADING: - Gv_SetVar(lVar2, g_player[iPlayer].ps->reloading, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->reloading); return; case PLAYER_AUTO_AIM: - Gv_SetVar(lVar2, g_player[iPlayer].ps->auto_aim, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->auto_aim); return; case PLAYER_MOVEMENT_LOCK: - Gv_SetVar(lVar2, g_player[iPlayer].ps->movement_lock, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->movement_lock); return; case PLAYER_SOUND_PITCH: - Gv_SetVar(lVar2, g_player[iPlayer].ps->sound_pitch, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->sound_pitch); return; case PLAYER_WEAPONSWITCH: - Gv_SetVar(lVar2, g_player[iPlayer].ps->weaponswitch, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->weaponswitch); return; case PLAYER_TEAM: - Gv_SetVar(lVar2, g_player[iPlayer].ps->team, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->team); return; case PLAYER_MAX_PLAYER_HEALTH: - Gv_SetVar(lVar2, g_player[iPlayer].ps->max_player_health, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->max_player_health); return; case PLAYER_MAX_SHIELD_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->max_shield_amount, vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->max_shield_amount); return; case PLAYER_MAX_AMMO_AMOUNT: - Gv_SetVar(lVar2, g_player[iPlayer].ps->max_ammo_amount[lParm2], vm.g_i, vm.g_p); return; + Gv_SetVarX(lVar2, g_player[iPlayer].ps->max_ammo_amount[lParm2]); return; case PLAYER_LAST_QUICK_KICK: - Gv_SetVar(lVar2, g_player[iPlayer].ps->last_quick_kick, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, g_player[iPlayer].ps->last_quick_kick); return; default: @@ -1534,7 +1534,7 @@ static void __fastcall VM_SetPlayer(int32_t lVar1, int32_t lLabelID, int32_t lVa register int32_t iPlayer=vm.g_p; if (lVar1 != g_iThisActorID) - iPlayer=Gv_GetVar(lVar1, vm.g_i, vm.g_p); + iPlayer=Gv_GetVarX(lVar1); if ((iPlayer<0 || iPlayer >= playerswhenstarted) /* && g_scriptSanityChecks */) goto badplayer; @@ -1542,7 +1542,7 @@ static void __fastcall VM_SetPlayer(int32_t lVar1, int32_t lLabelID, int32_t lVa if ((PlayerLabels[lLabelID].flags &LABEL_HASPARM2 && (lParm2 < 0 || lParm2 >= PlayerLabels[lLabelID].maxParm2)) /* && g_scriptSanityChecks */) goto badpos; - lVar1=Gv_GetVar(lVar2, vm.g_i, vm.g_p); + lVar1=Gv_GetVarX(lVar2); switch (lLabelID) { @@ -1589,11 +1589,11 @@ static void __fastcall VM_SetPlayer(int32_t lVar1, int32_t lLabelID, int32_t lVa case PLAYER_OPYOFF: g_player[iPlayer].ps->opyoff=lVar1; return; case PLAYER_POSXV: - g_player[iPlayer].ps->posvel.x=lVar1; return; + g_player[iPlayer].ps->vel.x=lVar1; return; case PLAYER_POSYV: - g_player[iPlayer].ps->posvel.y=lVar1; return; + g_player[iPlayer].ps->vel.y=lVar1; return; case PLAYER_POSZV: - g_player[iPlayer].ps->posvel.z=lVar1; return; + g_player[iPlayer].ps->vel.z=lVar1; return; case PLAYER_LAST_PISSED_TIME: g_player[iPlayer].ps->last_pissed_time=lVar1; return; case PLAYER_TRUEFZ: @@ -1881,13 +1881,13 @@ static void __fastcall VM_AccessPlayerInput(int32_t iSet, int32_t lVar1, int32_t int32_t iPlayer=vm.g_p; if (lVar1 != g_iThisActorID) - iPlayer=Gv_GetVar(lVar1, vm.g_i, vm.g_p); + iPlayer=Gv_GetVarX(lVar1); if ((iPlayer<0 || iPlayer >= playerswhenstarted) /* && g_scriptSanityChecks */) goto badplayer; if (iSet) - lValue=Gv_GetVar(lVar2, vm.g_i, vm.g_p); + lValue=Gv_GetVarX(lVar2); switch (lLabelID) { @@ -1897,7 +1897,7 @@ static void __fastcall VM_AccessPlayerInput(int32_t iSet, int32_t lVar1, int32_t g_player[iPlayer].sync->avel=lValue; return; } - Gv_SetVar(lVar2, g_player[iPlayer].sync->avel, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, g_player[iPlayer].sync->avel); return; case INPUT_HORZ: @@ -1906,7 +1906,7 @@ static void __fastcall VM_AccessPlayerInput(int32_t iSet, int32_t lVar1, int32_t g_player[iPlayer].sync->horz=lValue; return; } - Gv_SetVar(lVar2, g_player[iPlayer].sync->horz, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, g_player[iPlayer].sync->horz); return; case INPUT_FVEL: @@ -1915,7 +1915,7 @@ static void __fastcall VM_AccessPlayerInput(int32_t iSet, int32_t lVar1, int32_t g_player[iPlayer].sync->fvel=lValue; return; } - Gv_SetVar(lVar2, g_player[iPlayer].sync->fvel, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, g_player[iPlayer].sync->fvel); return; case INPUT_SVEL: @@ -1924,7 +1924,7 @@ static void __fastcall VM_AccessPlayerInput(int32_t iSet, int32_t lVar1, int32_t g_player[iPlayer].sync->svel=lValue; return; } - Gv_SetVar(lVar2, g_player[iPlayer].sync->svel, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, g_player[iPlayer].sync->svel); return; case INPUT_BITS: @@ -1933,7 +1933,7 @@ static void __fastcall VM_AccessPlayerInput(int32_t iSet, int32_t lVar1, int32_t g_player[iPlayer].sync->bits=lValue; return; } - Gv_SetVar(lVar2, g_player[iPlayer].sync->bits, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, g_player[iPlayer].sync->bits); return; case INPUT_EXTBITS: @@ -1942,7 +1942,7 @@ static void __fastcall VM_AccessPlayerInput(int32_t iSet, int32_t lVar1, int32_t g_player[iPlayer].sync->extbits=lValue; return; } - Gv_SetVar(lVar2, g_player[iPlayer].sync->extbits, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, g_player[iPlayer].sync->extbits); return; default: return; @@ -1957,13 +1957,13 @@ badplayer: static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabelID, int32_t lVar2) { int32_t lValue=0; - int32_t iWall = Gv_GetVar(lVar1, vm.g_i, vm.g_p); + int32_t iWall = Gv_GetVarX(lVar1); if ((iWall<0 || iWall >= numwalls) /* && g_scriptSanityChecks */) goto badwall; if (iSet) - lValue=Gv_GetVar(lVar2, vm.g_i, vm.g_p); + lValue=Gv_GetVarX(lVar2); switch (lLabelID) { @@ -1973,7 +1973,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].x=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].x, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].x); return; case WALL_Y: @@ -1982,7 +1982,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].y=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].y, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].y); return; case WALL_POINT2: @@ -1991,7 +1991,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].point2=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].point2, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].point2); return; case WALL_NEXTWALL: @@ -2000,7 +2000,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].nextwall=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].nextwall, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].nextwall); return; case WALL_NEXTSECTOR: @@ -2009,7 +2009,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].nextsector=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].nextsector, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].nextsector); return; case WALL_CSTAT: @@ -2018,7 +2018,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].cstat=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].cstat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].cstat); return; case WALL_PICNUM: @@ -2027,7 +2027,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].picnum=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].picnum, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].picnum); return; case WALL_OVERPICNUM: @@ -2036,7 +2036,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].overpicnum=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].overpicnum, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].overpicnum); return; case WALL_SHADE: @@ -2045,7 +2045,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].shade=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].shade, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].shade); return; case WALL_PAL: @@ -2054,7 +2054,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].pal=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].pal, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].pal); return; case WALL_XREPEAT: @@ -2063,7 +2063,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].xrepeat=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].xrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].xrepeat); return; case WALL_YREPEAT: @@ -2072,7 +2072,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].yrepeat=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].yrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].yrepeat); return; case WALL_XPANNING: @@ -2081,7 +2081,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].xpanning=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].xpanning, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].xpanning); return; case WALL_YPANNING: @@ -2090,7 +2090,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].ypanning=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].ypanning, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].ypanning); return; case WALL_LOTAG: @@ -2099,7 +2099,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].lotag=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].lotag, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].lotag); return; case WALL_HITAG: @@ -2108,7 +2108,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].hitag=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].hitag, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].hitag); return; case WALL_EXTRA: @@ -2117,7 +2117,7 @@ static void __fastcall VM_AccessWall(int32_t iSet, int32_t lVar1, int32_t lLabel wall[iWall].extra=lValue; return; } - Gv_SetVar(lVar2, wall[iWall].extra, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, wall[iWall].extra); return; default: return; @@ -2135,13 +2135,13 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab int32_t iSector=sprite[vm.g_i].sectnum; if (lVar1 != g_iThisActorID) - iSector=Gv_GetVar(lVar1, vm.g_i, vm.g_p); + iSector=Gv_GetVarX(lVar1); if ((iSector<0 || iSector >= numsectors) /* && g_scriptSanityChecks */) goto badsector; if (iSet) - lValue=Gv_GetVar(lVar2, vm.g_i, vm.g_p); + lValue=Gv_GetVarX(lVar2); switch (lLabelID) { @@ -2151,7 +2151,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].wallptr=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].wallptr,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].wallptr); return; case SECTOR_WALLNUM: @@ -2160,7 +2160,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].wallnum=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].wallnum,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].wallnum); return; case SECTOR_CEILINGZ: @@ -2169,7 +2169,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].ceilingz=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].ceilingz,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].ceilingz); return; case SECTOR_FLOORZ: @@ -2178,7 +2178,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].floorz=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].floorz,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].floorz); return; case SECTOR_CEILINGSTAT: @@ -2187,7 +2187,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].ceilingstat=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].ceilingstat,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].ceilingstat); return; case SECTOR_FLOORSTAT: @@ -2196,7 +2196,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].floorstat=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].floorstat,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].floorstat); return; case SECTOR_CEILINGPICNUM: @@ -2205,7 +2205,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].ceilingpicnum=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].ceilingpicnum,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].ceilingpicnum); return; case SECTOR_CEILINGSLOPE: @@ -2214,7 +2214,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].ceilingheinum=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].ceilingheinum,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].ceilingheinum); return; case SECTOR_CEILINGSHADE: @@ -2223,7 +2223,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].ceilingshade=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].ceilingshade,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].ceilingshade); return; case SECTOR_CEILINGPAL: @@ -2232,7 +2232,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].ceilingpal=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].ceilingpal,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].ceilingpal); return; case SECTOR_CEILINGXPANNING: @@ -2241,7 +2241,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].ceilingxpanning=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].ceilingxpanning,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].ceilingxpanning); return; case SECTOR_CEILINGYPANNING: @@ -2250,7 +2250,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].ceilingypanning=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].ceilingypanning,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].ceilingypanning); return; case SECTOR_FLOORPICNUM: @@ -2259,7 +2259,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].floorpicnum=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].floorpicnum,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].floorpicnum); return; case SECTOR_FLOORSLOPE: @@ -2268,7 +2268,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].floorheinum=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].floorheinum,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].floorheinum); return; case SECTOR_FLOORSHADE: @@ -2277,7 +2277,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].floorshade=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].floorshade,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].floorshade); return; case SECTOR_FLOORPAL: @@ -2286,7 +2286,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].floorpal=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].floorpal,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].floorpal); return; case SECTOR_FLOORXPANNING: @@ -2295,7 +2295,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].floorxpanning=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].floorxpanning,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].floorxpanning); return; case SECTOR_FLOORYPANNING: @@ -2304,7 +2304,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].floorypanning=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].floorypanning,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].floorypanning); return; case SECTOR_VISIBILITY: @@ -2313,7 +2313,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].visibility=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].visibility,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].visibility); return; case SECTOR_ALIGNTO: @@ -2322,7 +2322,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].filler=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].filler,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].filler); return; case SECTOR_LOTAG: @@ -2331,7 +2331,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].lotag=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].lotag,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].lotag); return; case SECTOR_HITAG: @@ -2340,7 +2340,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].hitag=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].hitag,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].hitag); return; case SECTOR_EXTRA: @@ -2349,7 +2349,7 @@ static void __fastcall VM_AccessSector(int32_t iSet, int32_t lVar1, int32_t lLab sector[iSector].extra=lValue; return; } - Gv_SetVar(lVar2, sector[iSector].extra,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sector[iSector].extra); return; default: @@ -2367,15 +2367,15 @@ static void __fastcall VM_SetSprite(int32_t lVar1, int32_t lLabelID, int32_t lVa register int32_t iActor=vm.g_i; if (lVar1 != g_iThisActorID) - iActor=Gv_GetVar(lVar1, vm.g_i, vm.g_p); + iActor=Gv_GetVarX(lVar1); - if ((iActor < 0 || iActor >= MAXSPRITES) /* && g_scriptSanityChecks */) + if ((unsigned)iActor >= MAXSPRITES) goto badactor; if ((ActorLabels[lLabelID].flags &LABEL_HASPARM2 && (lParm2 < 0 || lParm2 >= ActorLabels[lLabelID].maxParm2)) /* && g_scriptSanityChecks */) goto badpos; - lVar1=Gv_GetVar(lVar2, vm.g_i, vm.g_p); + lVar1=Gv_GetVarX(lVar2); switch (lLabelID) { @@ -2611,9 +2611,9 @@ static void __fastcall VM_GetSprite(int32_t lVar1, int32_t lLabelID, int32_t lVa register int32_t iActor=vm.g_i; if (lVar1 != g_iThisActorID) - iActor=Gv_GetVar(lVar1, vm.g_i, vm.g_p); + iActor=Gv_GetVarX(lVar1); - if ((iActor < 0 || iActor >= MAXSPRITES) /* && g_scriptSanityChecks */) + if ((unsigned)iActor >= MAXSPRITES) goto badactor; if ((ActorLabels[lLabelID].flags &LABEL_HASPARM2 && (lParm2 < 0 || lParm2 >= ActorLabels[lLabelID].maxParm2)) /* && g_scriptSanityChecks */) @@ -2622,211 +2622,211 @@ static void __fastcall VM_GetSprite(int32_t lVar1, int32_t lLabelID, int32_t lVa switch (lLabelID) { case ACTOR_X: - Gv_SetVar(lVar2, sprite[iActor].x,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].x); return; case ACTOR_Y: - Gv_SetVar(lVar2, sprite[iActor].y,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].y); return; case ACTOR_Z: - Gv_SetVar(lVar2, sprite[iActor].z,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].z); return; case ACTOR_CSTAT: - Gv_SetVar(lVar2, sprite[iActor].cstat,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].cstat); return; case ACTOR_PICNUM: - Gv_SetVar(lVar2, sprite[iActor].picnum,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].picnum); return; case ACTOR_SHADE: - Gv_SetVar(lVar2, sprite[iActor].shade,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].shade); return; case ACTOR_PAL: - Gv_SetVar(lVar2, sprite[iActor].pal,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].pal); return; case ACTOR_CLIPDIST: - Gv_SetVar(lVar2, sprite[iActor].clipdist,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].clipdist); return; case ACTOR_DETAIL: - Gv_SetVar(lVar2, sprite[iActor].filler,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].filler); return; case ACTOR_XREPEAT: - Gv_SetVar(lVar2, sprite[iActor].xrepeat,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].xrepeat); return; case ACTOR_YREPEAT: - Gv_SetVar(lVar2, sprite[iActor].yrepeat,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].yrepeat); return; case ACTOR_XOFFSET: - Gv_SetVar(lVar2, sprite[iActor].xoffset,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].xoffset); return; case ACTOR_YOFFSET: - Gv_SetVar(lVar2, sprite[iActor].yoffset,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].yoffset); return; case ACTOR_SECTNUM: - Gv_SetVar(lVar2, sprite[iActor].sectnum,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].sectnum); return; case ACTOR_STATNUM: - Gv_SetVar(lVar2, sprite[iActor].statnum,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].statnum); return; case ACTOR_ANG: - Gv_SetVar(lVar2, sprite[iActor].ang,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].ang); return; case ACTOR_OWNER: - Gv_SetVar(lVar2, sprite[iActor].owner,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].owner); return; case ACTOR_XVEL: - Gv_SetVar(lVar2, sprite[iActor].xvel,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].xvel); return; case ACTOR_YVEL: - Gv_SetVar(lVar2, sprite[iActor].yvel,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].yvel); return; case ACTOR_ZVEL: - Gv_SetVar(lVar2, sprite[iActor].zvel,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].zvel); return; case ACTOR_LOTAG: - Gv_SetVar(lVar2, sprite[iActor].lotag,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].lotag); return; case ACTOR_HITAG: - Gv_SetVar(lVar2, sprite[iActor].hitag,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].hitag); return; case ACTOR_EXTRA: - Gv_SetVar(lVar2, sprite[iActor].extra,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, sprite[iActor].extra); return; case ACTOR_HTCGG: - Gv_SetVar(lVar2, actor[iActor].cgg, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, actor[iActor].cgg); return; case ACTOR_HTPICNUM : - Gv_SetVar(lVar2, actor[iActor].picnum, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, actor[iActor].picnum); return; case ACTOR_HTANG: - Gv_SetVar(lVar2, actor[iActor].ang, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, actor[iActor].ang); return; case ACTOR_HTEXTRA: - Gv_SetVar(lVar2,actor[iActor].extra, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].extra); return; case ACTOR_HTOWNER: - Gv_SetVar(lVar2,actor[iActor].owner, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].owner); return; case ACTOR_HTMOVFLAG: - Gv_SetVar(lVar2,actor[iActor].movflag, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].movflag); return; case ACTOR_HTTEMPANG: - Gv_SetVar(lVar2,actor[iActor].tempang, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].tempang); return; case ACTOR_HTACTORSTAYPUT: - Gv_SetVar(lVar2,actor[iActor].actorstayput, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].actorstayput); return; case ACTOR_HTDISPICNUM: - Gv_SetVar(lVar2,actor[iActor].dispicnum, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].dispicnum); return; case ACTOR_HTTIMETOSLEEP: - Gv_SetVar(lVar2,actor[iActor].timetosleep, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].timetosleep); return; case ACTOR_HTFLOORZ: - Gv_SetVar(lVar2,actor[iActor].floorz, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].floorz); return; case ACTOR_HTCEILINGZ: - Gv_SetVar(lVar2,actor[iActor].ceilingz, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].ceilingz); return; case ACTOR_HTLASTVX: - Gv_SetVar(lVar2,actor[iActor].lastvx, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].lastvx); return; case ACTOR_HTLASTVY: - Gv_SetVar(lVar2,actor[iActor].lastvy, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].lastvy); return; case ACTOR_HTBPOSX: - Gv_SetVar(lVar2,actor[iActor].bposx, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].bposx); return; case ACTOR_HTBPOSY: - Gv_SetVar(lVar2,actor[iActor].bposy, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].bposy); return; case ACTOR_HTBPOSZ: - Gv_SetVar(lVar2,actor[iActor].bposz, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].bposz); return; case ACTOR_HTG_T: - Gv_SetVar(lVar2, actor[iActor].t_data[lParm2], vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, actor[iActor].t_data[lParm2]); return; case ACTOR_ANGOFF: - Gv_SetVar(lVar2,spriteext[iActor].angoff, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,spriteext[iActor].angoff); return; case ACTOR_PITCH: - Gv_SetVar(lVar2,spriteext[iActor].pitch, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,spriteext[iActor].pitch); return; case ACTOR_ROLL: - Gv_SetVar(lVar2,spriteext[iActor].roll, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,spriteext[iActor].roll); return; case ACTOR_MDXOFF: - Gv_SetVar(lVar2,spriteext[iActor].xoff, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,spriteext[iActor].xoff); return; case ACTOR_MDYOFF: - Gv_SetVar(lVar2,spriteext[iActor].yoff, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,spriteext[iActor].yoff); return; case ACTOR_MDZOFF: - Gv_SetVar(lVar2,spriteext[iActor].zoff, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,spriteext[iActor].zoff); return; case ACTOR_MDFLAGS: - Gv_SetVar(lVar2,spriteext[iActor].flags, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,spriteext[iActor].flags); return; case ACTOR_XPANNING: - Gv_SetVar(lVar2, spriteext[iActor].xpanning,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].xpanning); return; case ACTOR_YPANNING: - Gv_SetVar(lVar2, spriteext[iActor].ypanning,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].ypanning); return; case ACTOR_HTFLAGS: - Gv_SetVar(lVar2,actor[iActor].flags, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2,actor[iActor].flags); return; case ACTOR_ALPHA: - Gv_SetVar(lVar2, (uint8_t)(spriteext[iActor].alpha * 255.0f), vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, (uint8_t)(spriteext[iActor].alpha * 255.0f)); return; default: @@ -2854,13 +2854,13 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa int32_t iActor=vm.g_i; if (lVar1 != g_iThisActorID) - iActor=Gv_GetVar(lVar1, vm.g_i, vm.g_p); + iActor=Gv_GetVarX(lVar1); - if ((iActor < 0 || iActor >= MAXSPRITES) && g_scriptSanityChecks) + if ((unsigned)iActor >= MAXSPRITES) goto badsprite; if (iSet) - lValue=Gv_GetVar(lVar2, vm.g_i, vm.g_p); + lValue=Gv_GetVarX(lVar2); if ((!spriteext[iActor].tspr) && g_scriptSanityChecks) goto badtspr; @@ -2873,7 +2873,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->x=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->x,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->x); return; case ACTOR_Y: @@ -2882,7 +2882,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->y=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->y,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->y); return; case ACTOR_Z: @@ -2891,7 +2891,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->z=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->z,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->z); return; case ACTOR_CSTAT: @@ -2900,7 +2900,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->cstat=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->cstat,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->cstat); return; case ACTOR_PICNUM: @@ -2909,7 +2909,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->picnum=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->picnum,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->picnum); return; case ACTOR_SHADE: @@ -2918,7 +2918,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->shade=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->shade,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->shade); return; case ACTOR_PAL: @@ -2927,7 +2927,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->pal=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->pal,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->pal); return; case ACTOR_CLIPDIST: @@ -2936,7 +2936,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->clipdist=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->clipdist,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->clipdist); return; case ACTOR_DETAIL: @@ -2945,7 +2945,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->filler=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->filler,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->filler); return; case ACTOR_XREPEAT: @@ -2954,7 +2954,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->xrepeat=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->xrepeat,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->xrepeat); return; case ACTOR_YREPEAT: @@ -2963,7 +2963,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->yrepeat=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->yrepeat,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->yrepeat); return; case ACTOR_XOFFSET: @@ -2972,7 +2972,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->xoffset=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->xoffset,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->xoffset); return; case ACTOR_YOFFSET: @@ -2981,7 +2981,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->yoffset=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->yoffset,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->yoffset); return; case ACTOR_SECTNUM: @@ -2990,7 +2990,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->sectnum=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->sectnum,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->sectnum); return; case ACTOR_STATNUM: @@ -2999,7 +2999,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->statnum=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->statnum,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->statnum); return; case ACTOR_ANG: @@ -3008,7 +3008,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->ang=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->ang,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->ang); return; case ACTOR_OWNER: @@ -3017,7 +3017,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->owner=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->owner,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->owner); return; #if 1 @@ -3027,7 +3027,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->xvel=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->xvel,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->xvel); return; case ACTOR_YVEL: @@ -3036,7 +3036,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->yvel=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->yvel,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->yvel); return; case ACTOR_ZVEL: @@ -3045,7 +3045,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->zvel=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->zvel,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->zvel); return; case ACTOR_LOTAG: @@ -3054,7 +3054,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->lotag=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->lotag,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->lotag); return; case ACTOR_HITAG: @@ -3063,7 +3063,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->hitag=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->hitag,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->hitag); return; case ACTOR_EXTRA: @@ -3072,7 +3072,7 @@ static void __fastcall VM_AccessTsprite(int32_t iSet, int32_t lVar1, int32_t lLa spriteext[iActor].tspr->extra=lValue; return; } - Gv_SetVar(lVar2, spriteext[iActor].tspr->extra,vm.g_i,vm.g_p); + Gv_SetVarX(lVar2, spriteext[iActor].tspr->extra); return; #endif @@ -3098,7 +3098,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t goto badtile; if (iSet) - lValue=Gv_GetVar(lVar2, vm.g_i, vm.g_p); + lValue=Gv_GetVarX(lVar2); switch (lLabelID) { @@ -3108,7 +3108,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].workslike=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].workslike, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].workslike); return; case PROJ_SPAWNS: @@ -3117,7 +3117,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].spawns=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].spawns, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].spawns); return; case PROJ_SXREPEAT: @@ -3126,7 +3126,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].sxrepeat=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].sxrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].sxrepeat); return; case PROJ_SYREPEAT: @@ -3135,7 +3135,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].syrepeat=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].syrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].syrepeat); return; case PROJ_SOUND: @@ -3144,7 +3144,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].sound=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].sound, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].sound); return; case PROJ_ISOUND: @@ -3153,7 +3153,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].isound=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].isound, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].isound); return; case PROJ_VEL: @@ -3162,7 +3162,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].vel=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].vel, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].vel); return; case PROJ_EXTRA: @@ -3171,7 +3171,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].extra=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].extra, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].extra); return; case PROJ_DECAL: @@ -3180,7 +3180,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].decal=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].decal, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].decal); return; case PROJ_TRAIL: @@ -3189,7 +3189,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].trail=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].trail, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].trail); return; case PROJ_TXREPEAT: @@ -3198,7 +3198,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].txrepeat=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].txrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].txrepeat); return; case PROJ_TYREPEAT: @@ -3207,7 +3207,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].tyrepeat=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].tyrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].tyrepeat); return; case PROJ_TOFFSET: @@ -3216,7 +3216,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].toffset=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].toffset, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].toffset); return; case PROJ_TNUM: @@ -3225,7 +3225,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].tnum=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].tnum, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].tnum); return; case PROJ_DROP: @@ -3234,7 +3234,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].drop=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].drop, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].drop); return; case PROJ_CSTAT: @@ -3243,7 +3243,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].cstat=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].cstat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].cstat); return; case PROJ_CLIPDIST: @@ -3252,7 +3252,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].clipdist=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].clipdist, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].clipdist); return; case PROJ_SHADE: @@ -3261,7 +3261,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].shade=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].shade, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].shade); return; case PROJ_XREPEAT: @@ -3270,7 +3270,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].xrepeat=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].xrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].xrepeat); return; case PROJ_YREPEAT: @@ -3279,7 +3279,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].yrepeat=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].yrepeat, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].yrepeat); return; case PROJ_PAL: @@ -3288,7 +3288,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].pal=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].pal, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].pal); return; case PROJ_EXTRA_RAND: @@ -3297,7 +3297,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].extra_rand=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].extra_rand, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].extra_rand); return; case PROJ_HITRADIUS: @@ -3306,7 +3306,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].hitradius=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].hitradius, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].hitradius); return; case PROJ_VEL_MULT: @@ -3315,7 +3315,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].velmult=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].velmult, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].velmult); return; case PROJ_OFFSET: @@ -3324,7 +3324,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].offset=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].offset, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].offset); return; case PROJ_BOUNCES: @@ -3333,7 +3333,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].bounces=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].bounces, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].bounces); return; case PROJ_BSOUND: @@ -3342,7 +3342,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].bsound=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].bsound, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].bsound); return; case PROJ_RANGE: @@ -3351,7 +3351,7 @@ static void __fastcall VM_AccessProjectile(int32_t iSet, int32_t lVar1, int32_t ProjectileData[lVar1].range=lValue; return; } - Gv_SetVar(lVar2, ProjectileData[lVar1].range, vm.g_i, vm.g_p); + Gv_SetVarX(lVar2, ProjectileData[lVar1].range); return; default: @@ -3513,11 +3513,11 @@ static int32_t __fastcall VM_AccessPlayerX(int32_t iPlayer, int32_t lLabelID, in case PLAYER_OPYOFF: return g_player[iPlayer].ps->opyoff; case PLAYER_POSXV: - return g_player[iPlayer].ps->posvel.x; + return g_player[iPlayer].ps->vel.x; case PLAYER_POSYV: - return g_player[iPlayer].ps->posvel.y; + return g_player[iPlayer].ps->vel.y; case PLAYER_POSZV: - return g_player[iPlayer].ps->posvel.z; + return g_player[iPlayer].ps->vel.z; case PLAYER_LAST_PISSED_TIME: return g_player[iPlayer].ps->last_pissed_time; case PLAYER_TRUEFZ: diff --git a/polymer-perf/eduke32/source/gamevars.c b/polymer-perf/eduke32/source/gamevars.c index 1553f3b29..e87f0639b 100644 --- a/polymer-perf/eduke32/source/gamevars.c +++ b/polymer-perf/eduke32/source/gamevars.c @@ -635,10 +635,10 @@ int32_t __fastcall Gv_GetVar(register int32_t id, register int32_t iActor, regis default: return ((aGameVars[id].val.lValue ^ -negateResult) + negateResult); case GAMEVAR_PERPLAYER: - if (iPlayer < 0 || iPlayer >= MAXPLAYERS) goto bad_id; + if ((unsigned)iPlayer >= MAXPLAYERS) goto bad_id; return ((aGameVars[id].val.plValues[iPlayer] ^ -negateResult) + negateResult); case GAMEVAR_PERACTOR: - if (iActor < 0 || iActor >= MAXSPRITES) goto bad_id; + if ((unsigned)iActor >= MAXSPRITES) goto bad_id; return ((aGameVars[id].val.plValues[iActor] ^ -negateResult) + negateResult); case GAMEVAR_INTPTR: return (((*((int32_t *)aGameVars[id].val.lValue)) ^ -negateResult) + negateResult); @@ -667,12 +667,12 @@ void __fastcall Gv_SetVar(register int32_t id, register int32_t lValue, register aGameVars[id].val.lValue=lValue; return; case GAMEVAR_PERPLAYER: - if (iPlayer < 0 || iPlayer > MAXPLAYERS-1) goto badplayer; + if ((unsigned)iPlayer > MAXPLAYERS-1) goto badindex; // for the current player aGameVars[id].val.plValues[iPlayer]=lValue; return; case GAMEVAR_PERACTOR: - if (iActor < 0 || iActor > MAXSPRITES-1) goto badactor; + if ((unsigned)iActor > MAXSPRITES-1) goto badindex; aGameVars[id].val.plValues[iActor]=lValue; return; case GAMEVAR_INTPTR: @@ -691,14 +691,11 @@ badvarid: g_errorLineNum,keyw[g_tw],id,vm.g_i,sprite[vm.g_i].picnum,vm.g_p); return; -badplayer: - OSD_Printf(CON_ERROR "Gv_SetVar(): invalid player (%d) for gamevar %s from sprite %d, player %d\n", - g_errorLineNum,keyw[g_tw],iPlayer,aGameVars[id].szLabel,vm.g_i,vm.g_p); - return; - -badactor: - OSD_Printf(CON_ERROR "Gv_SetVar(): invalid actor (%d) for gamevar %s from sprite %d (%d), player %d\n", - g_errorLineNum,keyw[g_tw],iActor,aGameVars[id].szLabel,vm.g_i,sprite[vm.g_i].picnum,vm.g_p); +badindex: + OSD_Printf(CON_ERROR "Gv_SetVar(): invalid index (%d) for gamevar %s from sprite %d, player %d\n", + g_errorLineNum,keyw[g_tw], + aGameVars[id].dwFlags & GAMEVAR_PERACTOR ? iActor : iPlayer, + aGameVars[id].szLabel,vm.g_i,vm.g_p); return; } @@ -805,11 +802,11 @@ void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue) aGameVars[id].val.lValue=lValue; return; case GAMEVAR_PERPLAYER: - if (vm.g_p < 0 || vm.g_p > MAXPLAYERS-1) goto badplayer; + if ((unsigned)vm.g_p > MAXPLAYERS-1) goto badindex; aGameVars[id].val.plValues[vm.g_p]=lValue; return; case GAMEVAR_PERACTOR: - if (vm.g_i < 0 || vm.g_i > MAXSPRITES-1) goto badactor; + if ((unsigned)vm.g_i > MAXSPRITES-1) goto badindex; aGameVars[id].val.plValues[vm.g_i]=lValue; return; case GAMEVAR_INTPTR: @@ -823,14 +820,11 @@ void __fastcall Gv_SetVarX(register int32_t id, register int32_t lValue) return; } -badplayer: - OSD_Printf(CON_ERROR "Gv_SetVar(): invalid player (%d) for gamevar %s\n", - g_errorLineNum,keyw[g_tw],vm.g_p,aGameVars[id].szLabel); - return; - -badactor: - OSD_Printf(CON_ERROR "Gv_SetVar(): invalid actor (%d) for gamevar %s\n", - g_errorLineNum,keyw[g_tw],vm.g_i,aGameVars[id].szLabel); +badindex: + OSD_Printf(CON_ERROR "Gv_SetVar(): invalid index (%d) for gamevar %s\n", + g_errorLineNum,keyw[g_tw], + aGameVars[id].dwFlags & GAMEVAR_PERACTOR ? vm.g_i : vm.g_p, + aGameVars[id].szLabel); return; } @@ -1532,7 +1526,7 @@ static void Gv_AddSystemVars(void) Gv_NewVar("NUMSECTORS",(intptr_t)&numsectors, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_READONLY); Gv_NewVar("lastsavepos",(intptr_t)&g_lastSaveSlot, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); -#ifdef POLYMOST +#ifdef USE_OPENGL Gv_NewVar("rendmode",(intptr_t)&rendmode, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM | GAMEVAR_SYNCCHECK); #else Gv_NewVar("rendmode", 0, GAMEVAR_READONLY | GAMEVAR_SYSTEM | GAMEVAR_SYNCCHECK); @@ -1689,7 +1683,7 @@ void Gv_RefreshPointers(void) aGameVars[Gv_GetVarIndex("NUMSECTORS")].val.lValue = (intptr_t)&numsectors; aGameVars[Gv_GetVarIndex("lastsavepos")].val.lValue = (intptr_t)&g_lastSaveSlot; -#ifdef POLYMOST +#ifdef USE_OPENGL aGameVars[Gv_GetVarIndex("rendmode")].val.lValue = (intptr_t)&rendmode; #endif } diff --git a/polymer-perf/eduke32/source/global.c b/polymer-perf/eduke32/source/global.c index 103bf3fea..95aa23802 100644 --- a/polymer-perf/eduke32/source/global.c +++ b/polymer-perf/eduke32/source/global.c @@ -23,9 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define __global_c__ #include "global.h" #include "duke3d.h" +#include "rev.h" - -const char *s_buildDate = "20100727"; +const char *s_buildDate = "20110109"; char *MusicPtr = NULL; int32_t g_musicSize; diff --git a/polymer-perf/eduke32/source/global.h b/polymer-perf/eduke32/source/global.h index 53d348e63..1b0e9b47e 100644 --- a/polymer-perf/eduke32/source/global.h +++ b/polymer-perf/eduke32/source/global.h @@ -36,6 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MAXINTERPOLATIONS MAXSPRITES +G_EXTERN const char *s_buildRev; G_EXTERN DukeStatus_t sbar; G_EXTERN actor_t actor[MAXSPRITES]; G_EXTERN animwalltype animwall[MAXANIMWALLS]; diff --git a/polymer-perf/eduke32/source/grpscan.c b/polymer-perf/eduke32/source/grpscan.c index 3d8650230..72f6a5107 100644 --- a/polymer-perf/eduke32/source/grpscan.c +++ b/polymer-perf/eduke32/source/grpscan.c @@ -32,14 +32,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. struct grpfile grpfiles[numgrpfiles] = { - { "Duke Nukem 3D", 0xBBC9CE44, 26524524, GAMEDUKE, NULL }, - { "Duke Nukem 3D: Atomic Edition", 0xF514A6AC, 44348015, GAMEDUKE, NULL }, - { "Duke Nukem 3D: Atomic Edition", 0xFD3DCFF1, 44356548, GAMEDUKE, NULL }, - { "Duke Nukem 3D Shareware", 0x983AD923, 11035779, GAMEDUKE, NULL }, - { "Duke Nukem 3D Mac Shareware", 0xC5F71561, 10444391, GAMEDUKE, NULL }, - { "NAM", 0x75C1F07B, 43448927, GAMENAM, NULL }, - { "Napalm", 0x3DE1589A, 44365728, GAMENAM, NULL }, - { "WW2GI", 0x907B82BF, 77939508, GAMEWW2, NULL }, + { "Duke Nukem 3D", 0xBBC9CE44, 26524524, GAME_DUKE, NULL }, + { "Duke Nukem 3D: Atomic Edition", 0xF514A6AC, 44348015, GAME_DUKE, NULL }, + { "Duke Nukem 3D: Atomic Edition", 0xFD3DCFF1, 44356548, GAME_DUKE, NULL }, + { "Duke Nukem 3D Shareware", 0x983AD923, 11035779, GAME_DUKE, NULL }, + { "Duke Nukem 3D Mac Shareware", 0xC5F71561, 10444391, GAME_DUKE, NULL }, + { "NAM", 0x75C1F07B, 43448927, GAME_NAM, NULL }, + { "Napalm", 0x3DE1589A, 44365728, GAME_NAM, NULL }, + { "WW2GI", 0x907B82BF, 77939508, GAME_WW2, NULL }, }; struct grpfile *foundgrps = NULL; diff --git a/polymer-perf/eduke32/source/jaudiolib/src/multivoc.c b/polymer-perf/eduke32/source/jaudiolib/src/multivoc.c index be0881a14..bf1ec3e77 100644 --- a/polymer-perf/eduke32/source/jaudiolib/src/multivoc.c +++ b/polymer-perf/eduke32/source/jaudiolib/src/multivoc.c @@ -1012,14 +1012,13 @@ VoiceNode *MV_AllocVoice(int32_t priority) if (LL_Empty(&VoicePool, next, prev)) { // check if we have a higher priority than a voice that is playing. - voice = VoiceList.next; - for (node = voice->next; node != &VoiceList; node = node->next) + for (voice = node = VoiceList.next; node != &VoiceList; node = node->next) { if (node->priority < voice->priority) voice = node; } - if (priority >= voice->priority && voice->handle > MV_Ok) + if (priority >= voice->priority && voice != &VoiceList && voice->handle >= MV_MinVoiceHandle) MV_Kill(voice->handle); if (LL_Empty(&VoicePool, next, prev)) @@ -1074,14 +1073,14 @@ int32_t MV_VoiceAvailable(int32_t priority) voice = node; } - if ((voice != &VoiceList) && (priority >= voice->priority)) + if ((voice == &VoiceList) || (priority < voice->priority)) { RestoreInterrupts(); - return TRUE; + return FALSE; } RestoreInterrupts(); - return FALSE; + return TRUE; } diff --git a/polymer-perf/eduke32/source/m32def.c b/polymer-perf/eduke32/source/m32def.c index 231118a95..a0d70a034 100644 --- a/polymer-perf/eduke32/source/m32def.c +++ b/polymer-perf/eduke32/source/m32def.c @@ -363,6 +363,7 @@ const char *keyw[] = "printmessage256", "printext256", "printext16", + "drawlabel", "getnumber16", "getnumber256", "qsprintf", @@ -3266,14 +3267,18 @@ repeatcase: case CON_QUOTE: case CON_ERRORINS: case CON_PRINTMESSAGE16: + case CON_PRINTMESSAGE256: case CON_PRINTEXT256: case CON_PRINTEXT16: + case CON_DRAWLABEL: if (C_GetNextVarOrString()==-1) return 1; + if (tw==CON_PRINTMESSAGE256) C_GetManyVars(2); - else if (tw==CON_PRINTEXT256 || tw==CON_PRINTEXT16) + else if (tw >= CON_PRINTEXT256) C_GetManyVars(5); + return 0; case CON_GETNUMBER16: diff --git a/polymer-perf/eduke32/source/m32def.h b/polymer-perf/eduke32/source/m32def.h index 9da93f7df..fb6bd8375 100644 --- a/polymer-perf/eduke32/source/m32def.h +++ b/polymer-perf/eduke32/source/m32def.h @@ -467,6 +467,7 @@ enum ScriptKeywords_t CON_PRINTMESSAGE256, CON_PRINTEXT256, CON_PRINTEXT16, + CON_DRAWLABEL, CON_GETNUMBER16, CON_GETNUMBER256, CON_QSPRINTF, diff --git a/polymer-perf/eduke32/source/m32exec.c b/polymer-perf/eduke32/source/m32exec.c index 7989b7359..d9f76bbd4 100644 --- a/polymer-perf/eduke32/source/m32exec.c +++ b/polymer-perf/eduke32/source/m32exec.c @@ -60,7 +60,7 @@ static instype *x_sortingstateptr; extern void message(const char *fmt, ...); // from sector.c vvv -static int32_t ldist(spritetype *s1,spritetype *s2) +static int32_t ldist(const spritetype *s1, const spritetype *s2) { int32_t x= klabs(s1->x-s2->x); int32_t y= klabs(s1->y-s2->y); @@ -73,7 +73,7 @@ static int32_t ldist(spritetype *s1,spritetype *s2) } } -static int32_t dist(spritetype *s1,spritetype *s2) +static int32_t dist(const spritetype *s1, const spritetype *s2) { int32_t x= klabs(s1->x-s2->x); int32_t y= klabs(s1->y-s2->y); @@ -2385,6 +2385,7 @@ badindex: case CON_PRINTMESSAGE256: case CON_PRINTEXT256: case CON_PRINTEXT16: + case CON_DRAWLABEL: insptr++; { int32_t i=*insptr++; @@ -2395,30 +2396,55 @@ badindex: { int32_t x=(tw>=CON_PRINTMESSAGE256)?Gv_GetVarX(*insptr++):0; int32_t y=(tw>=CON_PRINTMESSAGE256)?Gv_GetVarX(*insptr++):0; + int32_t col=(tw>=CON_PRINTEXT256)?Gv_GetVarX(*insptr++):0; int32_t backcol=(tw>=CON_PRINTEXT256)?Gv_GetVarX(*insptr++):0; int32_t fontsize=(tw>=CON_PRINTEXT256)?Gv_GetVarX(*insptr++):0; - if (tw==CON_ERRORINS) vm.flags |= VMFLAG_ERROR; - if (tw==CON_PRINT || tw==CON_ERRORINS) + { OSD_Printf("%s\n", quotetext); + if (tw==CON_ERRORINS) + vm.flags |= VMFLAG_ERROR; + } else if (tw==CON_QUOTE) + { message("%s", quotetext); + } else if (tw==CON_PRINTMESSAGE16) - printmessage16("%s", quotetext); + { + if (qsetmode != 200) + printmessage16("%s", quotetext); + } else if (tw==CON_PRINTMESSAGE256) - printmessage256(x, y, quotetext); + { + if (qsetmode == 200) + printmessage256(x, y, quotetext); + } else if (tw==CON_PRINTEXT256) { - if (col<0 || col>=256) col=0; - if (backcol<0 || backcol>=256) backcol=-1; - printext256(x, y, col, backcol, quotetext, fontsize); + if (qsetmode == 200) + { + if (col<0 || col>=256) col=0; + if (backcol<0 || backcol>=256) backcol=-1; + printext256(x, y, col, backcol, quotetext, fontsize); + } } else if (tw==CON_PRINTEXT16) { - printext16(x, y, editorcolors[col&15], backcol<0 ? -1 : editorcolors[backcol&15], - quotetext, fontsize); + if (qsetmode != 200) + printext16(x, y, editorcolors[col&255], backcol<0 ? -1 : editorcolors[backcol&255], + quotetext, fontsize); + } + else if (tw==CON_DRAWLABEL) + { + if (qsetmode != 200) + { + drawsmallabel(quotetext, + editorcolors[backcol&255], // col + fontsize < 0 ? -1 : editorcolors[fontsize&255], // backcol + x, y, col); // x y z + } } } } diff --git a/polymer-perf/eduke32/source/m32vars.c b/polymer-perf/eduke32/source/m32vars.c index 93e324309..d312f744b 100644 --- a/polymer-perf/eduke32/source/m32vars.c +++ b/polymer-perf/eduke32/source/m32vars.c @@ -563,7 +563,7 @@ static void Gv_AddSystemVars(void) Gv_NewVar("numsprites",(intptr_t)&numsprites, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY); Gv_NewVar("numtiles",(intptr_t)&numtiles, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_READONLY); -#ifdef POLYMOST +#ifdef USE_OPENGL Gv_NewVar("rendmode",(intptr_t)&rendmode, GAMEVAR_READONLY | GAMEVAR_INTPTR | GAMEVAR_SYSTEM); #endif @@ -668,6 +668,8 @@ static void Gv_AddSystemVars(void) Gv_NewArray("tilesizx", (void *)tilesizx, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); Gv_NewArray("tilesizy", (void *)tilesizy, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT); +// Gv_NewArray("picsiz", (void *)picsiz, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFCHAR); + Gv_NewArray("picanm", (void *)picanm, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFINT); Gv_NewArray("show2dsector", (void *)show2dsector, (MAXSECTORS+7)>>3, GAMEARRAY_READONLY|GAMEARRAY_OFCHAR); Gv_NewArray("show2dwall", (void *)show2dwall, (MAXWALLS+7)>>3, GAMEARRAY_READONLY|GAMEARRAY_OFCHAR); diff --git a/polymer-perf/eduke32/source/macros.h b/polymer-perf/eduke32/source/macros.h index 53f18a10b..a964670ea 100644 --- a/polymer-perf/eduke32/source/macros.h +++ b/polymer-perf/eduke32/source/macros.h @@ -44,9 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TEST_SYNC_KEY(bits, sync_num) TEST(bits, BIT(sync_num)) -#define IFWITHIN(B,E) if((PN)>=(B) && (PN)<=(E)) -#define IFMOVING if(A_SetSprite(i,CLIPMASK0)) -#define IFHIT j=A_IncurDamage(i);if(j >= 0) +#define IFWITHIN(B,E) if ((PN)>=(B) && (PN)<=(E)) #define AFLAMABLE(X) (X==BOX||X==TREE1||X==TREE2||X==TIRE||X==CONE) #define rnd(X) ((krand()>>8)>=(255-(X))) diff --git a/polymer-perf/eduke32/source/mapster32.h b/polymer-perf/eduke32/source/mapster32.h index 7695f9c09..ce906157e 100644 --- a/polymer-perf/eduke32/source/mapster32.h +++ b/polymer-perf/eduke32/source/mapster32.h @@ -29,7 +29,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. const char *defsfilename = "duke3d.def"; extern char keystatus[]; -extern int16_t defaultspritecstat; extern int32_t horiz, qsetmode; extern vec3_t pos; extern int16_t ang, cursectnum; @@ -38,8 +37,6 @@ extern char names[MAXTILES][25]; extern int32_t ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d; -extern int32_t zmode, kensplayerheight, zlock; - extern int16_t editstatus, searchit; extern int32_t searchx, searchy, osearchx, osearchy; //search input extern int16_t searchsector, searchwall, searchstat; //search output @@ -48,10 +45,10 @@ extern int16_t searchbottomwall; #define COLOR_RED 248 #define COLOR_WHITE 31 -#define NUMOPTIONS 9 -char option[NUMOPTIONS] = {0,0,0,0,0,0,1,0,0}; +//#define NUMOPTIONS 9 +//char option[NUMOPTIONS] = {0,0,0,0,0,0,1,0,0}; -uint8_t keys[NUMBUILDKEYS] = +uint8_t default_buildkeys[NUMBUILDKEYS] = { 0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39, 0x1e,0x2c,0xd1,0xc9,0x47,0x49, @@ -68,7 +65,6 @@ extern void updatenumsprites(void); extern int32_t lastpm16time, synctics; extern int32_t halfxdim16, midydim16, zoom; -extern void fixrepeats(int16_t i); static char autospritehelp=0,autosecthelp=0; //int16_t MinRate=24, MinD=3; diff --git a/polymer-perf/eduke32/source/menus.c b/polymer-perf/eduke32/source/menus.c index 6ae70fd40..022aa2b59 100644 --- a/polymer-perf/eduke32/source/menus.c +++ b/polymer-perf/eduke32/source/menus.c @@ -2358,7 +2358,7 @@ cheat_for_port_credits: menutext(c,70+19+19+19,MENUHIGHLIGHT(3),PHX(-5),SkillNames[3]); break; case 230: -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL rotatesprite(320<<15,19<<16,65536L,0,MENUBAR,16,0,10,0,0,xdim-1,ydim-1); menutext(320>>1,24,0,0,"RENDERER SETUP"); @@ -2784,7 +2784,7 @@ cheat_for_port_credits: break; case 9: if (x==io) ud.screen_tilting = 1-ud.screen_tilting; -#ifdef POLYMOST +#ifdef USE_OPENGL if (!ud.screen_tilting) setrollangle(0); #endif modval(0,1,(int32_t *)&ud.screen_tilting,1,probey==io); @@ -3078,7 +3078,7 @@ cheat_for_port_credits: c = (320>>1)-120; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL x = (7/*+(getrendermode() >= 3)*/); #else x = 7; @@ -3282,7 +3282,7 @@ cheat_for_port_credits: nfs = newfullscreen; nbpp = (newvidmode==validmodecnt)?bpp:validmode[newvidmode].bpp; nrend = (vidsets[newvidset] & 0x20000) ? (nbpp==8?2: -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL glrendmode #else 0 @@ -3326,7 +3326,7 @@ cheat_for_port_credits: ud.detail = 1-ud.detail; break; } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL /* switch (gltexfiltermode) { case 0: @@ -3398,7 +3398,7 @@ cheat_for_port_credits: r_ambientlightrecip = 1.f/r_ambientlight; } } -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL else { int32_t filter = gltexfiltermode; @@ -5150,8 +5150,8 @@ VOLUME_ALL_40x: else if (g_netServer) enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE)); - Bsprintf(ScriptQuotes[116],"VOTE FAILED"); - P_DoQuote(116,g_player[myconnectindex].ps); + Bsprintf(ScriptQuotes[QUOTE_RESERVED2],"VOTE FAILED"); + P_DoQuote(QUOTE_RESERVED2,g_player[myconnectindex].ps); g_player[myconnectindex].ps->gm &= ~MODE_MENU; } } diff --git a/polymer-perf/eduke32/source/net.c b/polymer-perf/eduke32/source/net.c index 1be9a8eb5..37fae8e39 100644 --- a/polymer-perf/eduke32/source/net.c +++ b/polymer-perf/eduke32/source/net.c @@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. this should be lower than the MTU size by at least the size of the UDP and ENet headers or else fragmentation will occur */ -#define SYNCPACKETSIZE 1366 +#define SYNCPACKETSIZE 1344 ENetHost *g_netServer = NULL; ENetHost *g_netClient = NULL; @@ -44,15 +44,15 @@ int32_t g_netDisconnect = 0; char g_netPassword[32]; int32_t g_netSync = 0; int32_t g_netPlayersWaiting = 0; -int32_t g_netServerMode = 0; +int32_t g_networkMode = NET_CLIENT; static char recbuf[180]; static int32_t g_chatPlayer = -1; // sprites of these statnums are synced to clients by the server -int8_t g_netStatnums[8] = { STAT_PROJECTILE, STAT_STANDABLE, STAT_ACTIVATOR, STAT_TRANSPORT, - STAT_EFFECTOR, STAT_ACTOR, STAT_ZOMBIEACTOR, STAT_MISC - }; +int16_t g_netStatnums[10] = { STAT_PROJECTILE, STAT_PLAYER, STAT_STANDABLE, STAT_ACTIVATOR, STAT_TRANSPORT, + STAT_EFFECTOR, STAT_ACTOR, STAT_ZOMBIEACTOR, STAT_MISC, MAXSTATUS + }; int32_t lastupdate[MAXSPRITES]; int32_t lastsectupdate[MAXSECTORS]; @@ -279,12 +279,11 @@ void Net_NewGame(int32_t volume, int32_t level) static void Net_SendChallenge(void) { int32_t l = 1; - uint32_t crc = crc32once((uint8_t *)g_netPassword, Bstrlen(g_netPassword)); if (!g_netClientPeer) return; buf[0] = PACKET_AUTH; - *(uint32_t *)&buf[1] = crc; + *(uint32_t *)&buf[1] = crc32once((uint8_t *)g_netPassword, Bstrlen(g_netPassword)); l += sizeof(int32_t); buf[l++] = myconnectindex; @@ -328,8 +327,8 @@ static void P_RemovePlayer(int32_t i) voting = -1; } - Bstrcpy(ScriptQuotes[116],buf); - g_player[myconnectindex].ps->ftq = 116; + Bstrcpy(ScriptQuotes[QUOTE_RESERVED2],buf); + g_player[myconnectindex].ps->ftq = QUOTE_RESERVED2; g_player[myconnectindex].ps->fta = 180; } } @@ -343,11 +342,8 @@ void Net_SyncPlayer(ENetEvent *event) S_PlaySound(DUKE_GETWEAPON2); - TRAVERSE_CONNECT(i) - if (g_player[i].playerquitflag == 0) - break; - - // open a new slot if necessary + // open a new slot if necessary and save off the resulting slot # for future reference + TRAVERSE_CONNECT(i) if (g_player[i].playerquitflag == 0) break; event->peer->data = (void *)((intptr_t)(i = (i == -1 ? playerswhenstarted++ : i))); g_player[i].netsynctime = totalclock; @@ -356,19 +352,20 @@ void Net_SyncPlayer(ENetEvent *event) for (j=0; jpeer, CHAN_SYNC, - enet_packet_create((char *)(buf)+qlz_size_compressed(buf)-j, SYNCPACKETSIZE, ENET_PACKET_FLAG_RELIABLE)); + enet_packet_create((char *)(buf)+csize-j, SYNCPACKETSIZE, ENET_PACKET_FLAG_RELIABLE)); j -= SYNCPACKETSIZE; + enet_host_service(g_netServer, NULL, 0); } while (j >= SYNCPACKETSIZE); // ...except for this one. A non-SYNCPACKETSIZE packet on CHAN_SYNC doubles as the signal that the transfer is done. enet_peer_send(event->peer, CHAN_SYNC, - enet_packet_create((char *)(buf)+qlz_size_compressed(buf)-j, j, ENET_PACKET_FLAG_RELIABLE)); + enet_packet_create((char *)(buf)+csize-j, j, ENET_PACKET_FLAG_RELIABLE)); + enet_host_service(g_netServer, NULL, 0); } else initprintf("Error compressing map state for transfer!\n"); @@ -417,34 +418,160 @@ void Net_SyncPlayer(ENetEvent *event) int32_t Net_UnpackSprite(int32_t i, uint8_t *pbuf) { - int16_t sect, statnum, osect, ostatnum, jj, opicnum, j = 0; + int16_t sect = sprite[i].sectnum, statnum = sprite[i].statnum; + int16_t opicnum, j = 0; #ifdef POLYMER int16_t lightid = -1; _prlight *mylight = NULL; #endif - osect = sprite[i].sectnum; - ostatnum = sprite[i].statnum; + uint32_t flags = *(uint32_t *)&pbuf[j]; + j += sizeof(uint32_t); + opicnum = sprite[i].picnum; - Bmemcpy(&sprite[i], &pbuf[j], sizeof(spritetype)); - j += sizeof(spritetype); + if (flags & NET_SPRITE_X) + { + sprite[i].x = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } - sect = sprite[i].sectnum; - statnum = sprite[i].statnum; + if (flags & NET_SPRITE_Y) + { + sprite[i].y = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } + + if (flags & NET_SPRITE_Z) + { + sprite[i].z = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } + + if (flags & NET_SPRITE_SHADE) + { + sprite[i].shade = *(int8_t *)&pbuf[j]; + j += sizeof(int8_t); + } + + if (flags & NET_SPRITE_PAL) + { + sprite[i].pal = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_SPRITE_CLIPDIST) + { + sprite[i].clipdist = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_SPRITE_XREPEAT) + { + sprite[i].xrepeat = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_SPRITE_YREPEAT) + { + sprite[i].yrepeat = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_SPRITE_XOFFSET) + { + sprite[i].xoffset = *(int8_t *)&pbuf[j]; + j += sizeof(int8_t); + } + + if (flags & NET_SPRITE_YOFFSET) + { + sprite[i].yoffset = *(int8_t *)&pbuf[j]; + j += sizeof(int8_t); + } + + if (flags & NET_SPRITE_SECTNUM) + { + sect = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SPRITE_STATNUM) + { + statnum = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SPRITE_ANG) + { + sprite[i].ang = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SPRITE_OWNER) + { + sprite[i].owner = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SPRITE_XVEL) + { + sprite[i].xvel = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SPRITE_YVEL) + { + sprite[i].yvel = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SPRITE_ZVEL) + { + sprite[i].zvel = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SPRITE_LOTAG) + { + sprite[i].lotag = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SPRITE_HITAG) + { + sprite[i].hitag = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SPRITE_EXTRA) + { + sprite[i].extra = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SPRITE_CSTAT) + { + sprite[i].cstat = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SPRITE_PICNUM) + { + sprite[i].picnum = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } if (sect == MAXSECTORS || statnum == MAXSTATUS) { - j += sizeof(netactor_t); - deletesprite(i); +// j += sizeof(netactor_t); + if (sprite[i].sectnum != MAXSECTORS && sprite[i].statnum != MAXSTATUS) + deletesprite(i); return j; } - sprite[i].sectnum = osect; - sprite[i].statnum = ostatnum; - // doesn't exist on the client yet - if (ostatnum == MAXSTATUS || osect == MAXSECTORS) + if (sprite[i].statnum == MAXSTATUS || sprite[i].sectnum == MAXSECTORS) { int16_t sprs[MAXSPRITES], z = 0; while ((sprs[z++] = insertsprite(sect, statnum)) != i); @@ -453,8 +580,8 @@ int32_t Net_UnpackSprite(int32_t i, uint8_t *pbuf) } else { - if (sect != osect) changespritesect(i, sect); - if (statnum != ostatnum) changespritestat(i, statnum); + if (sect != sprite[i].sectnum) changespritesect(i, sect); + if (statnum != sprite[i].statnum) changespritestat(i, statnum); } #ifdef POLYMER if (sprite[i].picnum == opicnum) @@ -472,10 +599,122 @@ int32_t Net_UnpackSprite(int32_t i, uint8_t *pbuf) /*initprintf("updating sprite %d (%d)\n",i,sprite[i].picnum);*/ - jj = j++; + flags = *(uint32_t *)&pbuf[j]; + j += sizeof(uint32_t); - Bmemcpy(&actor[i], &pbuf[j], sizeof(netactor_t)); - j += sizeof(netactor_t); + if (flags & NET_ACTOR_T1) + { + actor[i].t_data[0] = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } + + if (flags & NET_ACTOR_T2) + { + actor[i].t_data[1] = *(int32_t *)&pbuf[j]; + if (flags & NET_ACTOR_PTR1) + actor[i].t_data[1] += (intptr_t)&script[0]; + j += sizeof(int32_t); + } + + if (flags & NET_ACTOR_T3) + { + actor[i].t_data[2] = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } + + if (flags & NET_ACTOR_T4) + { + actor[i].t_data[3] = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } + + if (flags & NET_ACTOR_T5) + { + actor[i].t_data[4] = *(int32_t *)&pbuf[j]; + if (flags & NET_ACTOR_PTR2) + actor[i].t_data[4] += (intptr_t)&script[0]; + j += sizeof(int32_t); + } + + if (flags & NET_ACTOR_T6) + { + actor[i].t_data[5] = *(int32_t *)&pbuf[j]; + if (flags & NET_ACTOR_PTR3) + actor[i].t_data[5] += (intptr_t)&script[0]; + j += sizeof(int32_t); + } + + if (flags & NET_ACTOR_T7) + { + actor[i].t_data[6] = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } + + if (flags & NET_ACTOR_T8) + { + actor[i].t_data[7] = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } + + if (flags & NET_ACTOR_T9) + { + actor[i].t_data[8] = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } + + if (flags & NET_ACTOR_T10) + { + actor[i].t_data[9] = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } + + if (flags & NET_ACTOR_PICNUM) + { + actor[i].picnum = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_ACTOR_ANG) + { + actor[i].ang = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_ACTOR_EXTRA) + { + actor[i].extra = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_ACTOR_OWNER) + { + actor[i].owner = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_ACTOR_MOVFLAG) + { + actor[i].movflag = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_ACTOR_TEMPANG) + { + actor[i].tempang = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_ACTOR_TIMETOSLEEP) + { + actor[i].timetosleep = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_ACTOR_FLAGS) + { + actor[i].flags = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } actor[i].projectile = &SpriteProjectile[i]; #ifdef POLYMER @@ -485,10 +724,6 @@ int32_t Net_UnpackSprite(int32_t i, uint8_t *pbuf) actor[i].flags &= ~SPRITE_NULL; - if (pbuf[jj] & 1) T2 += (intptr_t)&script[0]; - if (pbuf[jj] & 2) T5 += (intptr_t)&script[0]; - if (pbuf[jj] & 4) T6 += (intptr_t)&script[0]; - do { int16_t var_id = *(int16_t *)&pbuf[j]; @@ -508,44 +743,345 @@ int32_t Net_UnpackSprite(int32_t i, uint8_t *pbuf) int32_t Net_PackSprite(int32_t i, uint8_t *pbuf) { - int32_t j = 0, jj; + int32_t j = 0; + uint32_t *flags; + static spritetype netsprite[MAXSPRITES]; + static netactor_t netactor[MAXSPRITES]; + + if (lastupdate[i] && !Bmemcmp(&sprite[i], &netsprite[i], sizeof(spritetype))) + return 0; *(int16_t *)&pbuf[j] = i; j += sizeof(int16_t); - Bmemcpy(&pbuf[j], &sprite[i], sizeof(spritetype)); - j += sizeof(spritetype); - pbuf[(jj = j++)] = 0; + flags = (uint32_t *)&pbuf[j]; + *flags = 0; + j += sizeof(uint32_t); - if (T2 >= (intptr_t)&script[0] && T2 < (intptr_t)(&script[g_scriptSize])) + if (sprite[i].sectnum == MAXSECTORS || sprite[i].statnum == MAXSTATUS) { - pbuf[jj] |= 1; - T2 -= (intptr_t)&script[0]; + *flags = NET_SPRITE_SECTNUM; + *(int16_t *)&pbuf[j] = MAXSECTORS; + j += sizeof(int16_t); + + Bmemcpy(&netsprite[i], &sprite[i], sizeof(spritetype)); + return j; } - if (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)(&script[g_scriptSize])) + if (!lastupdate[i] || sprite[i].x != netsprite[i].x) { - pbuf[jj] |= 2; - T5 -= (intptr_t)&script[0]; + *flags |= NET_SPRITE_X; + *(int32_t *)&pbuf[j] = sprite[i].x; + j += sizeof(int32_t); } - if (T6 >= (intptr_t)&script[0] && T6 < (intptr_t)(&script[g_scriptSize])) + if (!lastupdate[i] || sprite[i].y != netsprite[i].y) { - pbuf[jj] |= 4; - T6 -= (intptr_t)&script[0]; + *flags |= NET_SPRITE_Y; + *(int32_t *)&pbuf[j] = sprite[i].y; + j += sizeof(int32_t); } - Bmemcpy(&pbuf[j], &actor[i], sizeof(netactor_t)); - j += sizeof(netactor_t); + if (!lastupdate[i] || sprite[i].z != netsprite[i].z) + { + *flags |= NET_SPRITE_Z; + *(int32_t *)&pbuf[j] = sprite[i].z; + j += sizeof(int32_t); + } - if (pbuf[jj] & 1) T2 += (intptr_t)&script[0]; - if (pbuf[jj] & 2) T5 += (intptr_t)&script[0]; - if (pbuf[jj] & 4) T6 += (intptr_t)&script[0]; + if (!lastupdate[i] || sprite[i].shade != netsprite[i].shade) + { + *flags |= NET_SPRITE_SHADE; + *(int8_t *)&pbuf[j] = sprite[i].shade; + j += sizeof(int8_t); + } + + if (!lastupdate[i] || sprite[i].pal != netsprite[i].pal) + { + *flags |= NET_SPRITE_PAL; + *(uint8_t *)&pbuf[j] = sprite[i].pal; + j += sizeof(uint8_t); + } + + if (!lastupdate[i] || sprite[i].clipdist != netsprite[i].clipdist) + { + *flags |= NET_SPRITE_CLIPDIST; + *(uint8_t *)&pbuf[j] = sprite[i].clipdist; + j += sizeof(uint8_t); + } + + if (!lastupdate[i] || sprite[i].xrepeat != netsprite[i].xrepeat) + { + *flags |= NET_SPRITE_XREPEAT; + *(uint8_t *)&pbuf[j] = sprite[i].xrepeat; + j += sizeof(uint8_t); + } + + if (!lastupdate[i] || sprite[i].yrepeat != netsprite[i].yrepeat) + { + *flags |= NET_SPRITE_YREPEAT; + *(uint8_t *)&pbuf[j] = sprite[i].yrepeat; + j += sizeof(uint8_t); + } + + if (!lastupdate[i] || sprite[i].xoffset != netsprite[i].xoffset) + { + *flags |= NET_SPRITE_XOFFSET; + *(int8_t *)&pbuf[j] = sprite[i].xoffset; + j += sizeof(int8_t); + } + + if (!lastupdate[i] || sprite[i].yoffset != netsprite[i].yoffset) + { + *flags |= NET_SPRITE_YOFFSET; + *(int8_t *)&pbuf[j] = sprite[i].yoffset; + j += sizeof(int8_t); + } + + if (!lastupdate[i] || sprite[i].sectnum != netsprite[i].sectnum || sprite[i].sectnum == MAXSECTORS) + { + *flags |= NET_SPRITE_SECTNUM; + *(int16_t *)&pbuf[j] = sprite[i].sectnum; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || sprite[i].statnum != netsprite[i].statnum || sprite[i].statnum == MAXSTATUS) + { + *flags |= NET_SPRITE_STATNUM; + *(int16_t *)&pbuf[j] = sprite[i].statnum; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || sprite[i].ang != netsprite[i].ang) + { + *flags |= NET_SPRITE_ANG; + *(int16_t *)&pbuf[j] = sprite[i].ang; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || sprite[i].owner != netsprite[i].owner) + { + *flags |= NET_SPRITE_OWNER; + *(int16_t *)&pbuf[j] = sprite[i].owner; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || sprite[i].xvel != netsprite[i].xvel) + { + *flags |= NET_SPRITE_XVEL; + *(int16_t *)&pbuf[j] = sprite[i].xvel; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || sprite[i].yvel != netsprite[i].yvel) + { + *flags |= NET_SPRITE_YVEL; + *(int16_t *)&pbuf[j] = sprite[i].yvel; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || sprite[i].zvel != netsprite[i].zvel) + { + *flags |= NET_SPRITE_ZVEL; + *(int16_t *)&pbuf[j] = sprite[i].zvel; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || sprite[i].lotag != netsprite[i].lotag) + { + *flags |= NET_SPRITE_LOTAG; + *(int16_t *)&pbuf[j] = sprite[i].lotag; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || sprite[i].hitag != netsprite[i].hitag) + { + *flags |= NET_SPRITE_HITAG; + *(int16_t *)&pbuf[j] = sprite[i].hitag; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || sprite[i].extra != netsprite[i].extra) + { + *flags |= NET_SPRITE_EXTRA; + *(int16_t *)&pbuf[j] = sprite[i].extra; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || sprite[i].cstat != netsprite[i].cstat) + { + *flags |= NET_SPRITE_CSTAT; + *(int16_t *)&pbuf[j] = sprite[i].cstat; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || sprite[i].picnum != netsprite[i].picnum) + { + *flags |= NET_SPRITE_PICNUM; + *(int16_t *)&pbuf[j] = sprite[i].picnum; + j += sizeof(int16_t); + } + + if (lastupdate[i]) + Bmemcpy(&netsprite[i], &sprite[i], sizeof(spritetype)); + + flags = (uint32_t *)&pbuf[j]; + *flags = 0; + j += sizeof(uint32_t); + + if (!lastupdate[i] || actor[i].t_data[0] != netactor[i].t_data[0]) + { + *flags |= NET_ACTOR_T1; + *(int32_t *)&pbuf[j] = actor[i].t_data[0]; + j += sizeof(int32_t); + } + + if (!lastupdate[i] || actor[i].t_data[1] != netactor[i].t_data[1]) + { + *flags |= NET_ACTOR_T2; + + if (T2 >= (intptr_t)&script[0] && T2 < (intptr_t)(&script[g_scriptSize])) + { + *flags |= NET_ACTOR_PTR1; + *(int32_t *)&pbuf[j] = (int32_t)(actor[i].t_data[1] - (intptr_t)&script[0]); + } + else *(int32_t *)&pbuf[j] = actor[i].t_data[1]; + j += sizeof(int32_t); + } + + if (!lastupdate[i] || actor[i].t_data[2] != netactor[i].t_data[2]) + { + *flags |= NET_ACTOR_T3; + *(int32_t *)&pbuf[j] = actor[i].t_data[2]; + j += sizeof(int32_t); + } + + if (!lastupdate[i] || actor[i].t_data[3] != netactor[i].t_data[3]) + { + *flags |= NET_ACTOR_T4; + *(int32_t *)&pbuf[j] = actor[i].t_data[3]; + j += sizeof(int32_t); + } + + if (!lastupdate[i] || actor[i].t_data[4] != netactor[i].t_data[4]) + { + *flags |= NET_ACTOR_T5; + + if (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)(&script[g_scriptSize])) + { + *flags |= NET_ACTOR_PTR2; + *(int32_t *)&pbuf[j] = (int32_t)(actor[i].t_data[4] - (intptr_t)&script[0]); + } + else *(int32_t *)&pbuf[j] = actor[i].t_data[4]; + j += sizeof(int32_t); + } + + if (!lastupdate[i] || actor[i].t_data[5] != netactor[i].t_data[5]) + { + *flags |= NET_ACTOR_T6; + if (T6 >= (intptr_t)&script[0] && T6 < (intptr_t)(&script[g_scriptSize])) + { + *flags |= NET_ACTOR_PTR3; + *(int32_t *)&pbuf[j] = (int32_t)(actor[i].t_data[5] - (intptr_t)&script[0]); + } + else *(int32_t *)&pbuf[j] = actor[i].t_data[5]; + j += sizeof(int32_t); + } + + if (!lastupdate[i] || actor[i].t_data[6] != netactor[i].t_data[6]) + { + *flags |= NET_ACTOR_T7; + *(int32_t *)&pbuf[j] = actor[i].t_data[6]; + j += sizeof(int32_t); + } + + if (!lastupdate[i] || actor[i].t_data[7] != netactor[i].t_data[7]) + { + *flags |= NET_ACTOR_T8; + *(int32_t *)&pbuf[j] = actor[i].t_data[7]; + j += sizeof(int32_t); + } + + if (!lastupdate[i] || actor[i].t_data[8] != netactor[i].t_data[8]) + { + *flags |= NET_ACTOR_T9; + *(int32_t *)&pbuf[j] = actor[i].t_data[8]; + j += sizeof(int32_t); + } + + if (!lastupdate[i] || actor[i].t_data[9] != netactor[i].t_data[9]) + { + *flags |= NET_ACTOR_T10; + *(int32_t *)&pbuf[j] = actor[i].t_data[9]; + j += sizeof(int32_t); + } + + if (!lastupdate[i] || actor[i].picnum != netactor[i].picnum) + { + *flags |= NET_ACTOR_PICNUM; + *(int16_t *)&pbuf[j] = actor[i].picnum; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || actor[i].ang != netactor[i].ang) + { + *flags |= NET_ACTOR_ANG; + *(int16_t *)&pbuf[j] = actor[i].ang; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || actor[i].extra != netactor[i].extra) + { + *flags |= NET_ACTOR_EXTRA; + *(int16_t *)&pbuf[j] = actor[i].extra; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || actor[i].owner!= netactor[i].owner) + { + *flags |= NET_ACTOR_OWNER; + *(int16_t *)&pbuf[j] = actor[i].owner; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || actor[i].movflag != netactor[i].movflag) + { + *flags |= NET_ACTOR_MOVFLAG; + *(int16_t *)&pbuf[j] = actor[i].movflag; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || actor[i].tempang != netactor[i].tempang) + { + *flags |= NET_ACTOR_TEMPANG; + *(int16_t *)&pbuf[j] = actor[i].tempang; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || actor[i].timetosleep != netactor[i].timetosleep) + { + *flags |= NET_ACTOR_TIMETOSLEEP; + *(int16_t *)&pbuf[j] = actor[i].timetosleep; + j += sizeof(int16_t); + } + + if (!lastupdate[i] || actor[i].flags != netactor[i].flags) + { + *flags |= NET_ACTOR_FLAGS; + *(int32_t *)&pbuf[j] = actor[i].flags; + j += sizeof(int32_t); + } + + if (lastupdate[i]) + Bmemcpy(&netactor[i], &actor[i], sizeof(netactor_t)); + + if (*flags == 0) + return 0; { - int16_t ii=g_gameVarCount-1, kk = 0; + int16_t ii=g_gameVarCount-1; - for (; ii>=0 && kk <= 64; ii--) + for (; ii>=0; ii--) { if ((aGameVars[ii].dwFlags & (GAMEVAR_PERACTOR|GAMEVAR_NOMULTI)) == GAMEVAR_PERACTOR && aGameVars[ii].val.plValues) { @@ -555,10 +1091,10 @@ int32_t Net_PackSprite(int32_t i, uint8_t *pbuf) j += sizeof(int16_t); *(int32_t *)&pbuf[j] = aGameVars[ii].val.plValues[i]; j += sizeof(int32_t); - kk++; } } } + *(int16_t *)&pbuf[j] = MAXGAMEVARS; j += sizeof(int16_t); } @@ -566,11 +1102,584 @@ int32_t Net_PackSprite(int32_t i, uint8_t *pbuf) return j; } +int32_t Net_UnpackSect(int32_t i, uint8_t *pbuf) +{ + int32_t j = 0; + uint32_t flags = *(uint32_t *)&pbuf[j]; + + j += sizeof(uint32_t); + + if (flags & NET_SECTOR_WALLPTR) + { + sector[i].wallptr = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SECTOR_WALLNUM) + { + sector[i].wallnum = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SECTOR_CEILINGZ) + { + sector[i].ceilingz = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } + + if (flags & NET_SECTOR_FLOORZ) + { + sector[i].floorz = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } + + if (flags & NET_SECTOR_CEILINGSTAT) + { + sector[i].ceilingstat = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SECTOR_FLOORSTAT) + { + sector[i].floorstat = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SECTOR_CEILINGPIC) + { + sector[i].ceilingpicnum = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SECTOR_CEILINGSLOPE) + { + sector[i].ceilingheinum = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SECTOR_CEILINGSHADE) + { + sector[i].ceilingshade = *(int8_t *)&pbuf[j]; + j += sizeof(int8_t); + } + + if (flags & NET_SECTOR_CEILINGPAL) + { + sector[i].ceilingpal = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_SECTOR_CEILINGXPAN) + { + sector[i].ceilingxpanning = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_SECTOR_CEILINGYPAN) + { + sector[i].ceilingypanning = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_SECTOR_FLOORPIC) + { + sector[i].floorpicnum = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SECTOR_FLOORSLOPE) + { + sector[i].floorheinum = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SECTOR_FLOORSHADE) + { + sector[i].floorshade = *(int8_t *)&pbuf[j]; + j += sizeof(int8_t); + } + + if (flags & NET_SECTOR_FLOORPAL) + { + sector[i].floorpal = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_SECTOR_FLOORXPAN) + { + sector[i].floorxpanning = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_SECTOR_FLOORYPAN) + { + sector[i].floorypanning = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_SECTOR_VISIBILITY) + { + sector[i].visibility = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_SECTOR_LOTAG) + { + sector[i].lotag = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SECTOR_HITAG) + { + sector[i].hitag = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_SECTOR_EXTRA) + { + sector[i].extra = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + return j; +} + +int32_t Net_PackSect(int32_t i, uint8_t *pbuf) +{ + int32_t j = 0; + uint32_t *flags; + static sectortype netsect[MAXSECTORS]; + + if (lastsectupdate[i] && !Bmemcmp(§or[i], &netsect[i], sizeof(sectortype))) + return 0; + + *(int16_t *)&pbuf[j] = i; + j += sizeof(int16_t); + + flags = (uint32_t *)&pbuf[j]; + *flags = 0; + j += sizeof(uint32_t); + + if (!lastsectupdate[i] || sector[i].wallptr != netsect[i].wallptr) + { + *flags |= NET_SECTOR_WALLPTR; + *(int16_t *)&pbuf[j] = sector[i].wallptr; + j += sizeof(int16_t); + } + + if (!lastsectupdate[i] || sector[i].wallnum != netsect[i].wallnum) + { + *flags |= NET_SECTOR_WALLNUM; + *(int16_t *)&pbuf[j] = sector[i].wallnum; + j += sizeof(int16_t); + } + + if (!lastsectupdate[i] || sector[i].ceilingz != netsect[i].ceilingz) + { + *flags |= NET_SECTOR_CEILINGZ; + *(int32_t *)&pbuf[j] = sector[i].ceilingz; + j += sizeof(int32_t); + } + + if (!lastsectupdate[i] || sector[i].floorz != netsect[i].floorz) + { + *flags |= NET_SECTOR_FLOORZ; + *(int32_t *)&pbuf[j] = sector[i].floorz; + j += sizeof(int32_t); + } + + if (!lastsectupdate[i] || sector[i].ceilingstat != netsect[i].ceilingstat) + { + *flags |= NET_SECTOR_CEILINGSTAT; + *(int16_t *)&pbuf[j] = sector[i].ceilingstat; + j += sizeof(int16_t); + } + + if (!lastsectupdate[i] || sector[i].floorstat != netsect[i].floorstat) + { + *flags |= NET_SECTOR_FLOORSTAT; + *(int16_t *)&pbuf[j] = sector[i].floorstat; + j += sizeof(int16_t); + } + + if (!lastsectupdate[i] || sector[i].ceilingpicnum != netsect[i].ceilingpicnum) + { + *flags |= NET_SECTOR_CEILINGPIC; + *(int16_t *)&pbuf[j] = sector[i].ceilingpicnum; + j += sizeof(int16_t); + } + + if (!lastsectupdate[i] || sector[i].ceilingheinum != netsect[i].ceilingheinum) + { + *flags |= NET_SECTOR_CEILINGSLOPE; + *(int16_t *)&pbuf[j] = sector[i].ceilingheinum; + j += sizeof(int16_t); + } + + if (!lastsectupdate[i] || sector[i].ceilingshade != netsect[i].ceilingshade) + { + *flags |= NET_SECTOR_CEILINGSHADE; + *(int8_t *)&pbuf[j] = sector[i].ceilingshade; + j += sizeof(int8_t); + } + + if (!lastsectupdate[i] || sector[i].ceilingpal != netsect[i].ceilingpal) + { + *flags |= NET_SECTOR_CEILINGPAL; + *(uint8_t *)&pbuf[j] = sector[i].ceilingpal; + j += sizeof(uint8_t); + } + + if (!lastsectupdate[i] || sector[i].ceilingxpanning != netsect[i].ceilingxpanning) + { + *flags |= NET_SECTOR_CEILINGXPAN; + *(uint8_t *)&pbuf[j] = sector[i].ceilingxpanning; + j += sizeof(uint8_t); + } + + if (!lastsectupdate[i] || sector[i].ceilingypanning != netsect[i].ceilingypanning) + { + *flags |= NET_SECTOR_CEILINGYPAN; + *(uint8_t *)&pbuf[j] = sector[i].ceilingypanning; + j += sizeof(uint8_t); + } + + if (!lastsectupdate[i] || sector[i].floorpicnum != netsect[i].floorpicnum) + { + *flags |= NET_SECTOR_FLOORPIC; + *(int16_t *)&pbuf[j] = sector[i].floorpicnum; + j += sizeof(int16_t); + } + + if (!lastsectupdate[i] || sector[i].floorheinum != netsect[i].floorheinum) + { + *flags |= NET_SECTOR_FLOORSLOPE; + *(int16_t *)&pbuf[j] = sector[i].floorheinum; + j += sizeof(int16_t); + } + + if (!lastsectupdate[i] || sector[i].floorshade != netsect[i].floorshade) + { + *flags |= NET_SECTOR_FLOORSHADE; + *(int8_t *)&pbuf[j] = sector[i].floorshade; + j += sizeof(int8_t); + } + + if (!lastsectupdate[i] || sector[i].floorpal != netsect[i].floorpal) + { + *flags |= NET_SECTOR_FLOORPAL; + *(uint8_t *)&pbuf[j] = sector[i].floorpal; + j += sizeof(uint8_t); + } + + if (!lastsectupdate[i] || sector[i].floorxpanning != netsect[i].floorxpanning) + { + *flags |= NET_SECTOR_FLOORXPAN; + *(uint8_t *)&pbuf[j] = sector[i].floorxpanning; + j += sizeof(uint8_t); + } + + if (!lastsectupdate[i] || sector[i].floorypanning != netsect[i].floorypanning) + { + *flags |= NET_SECTOR_FLOORYPAN; + *(uint8_t *)&pbuf[j] = sector[i].floorypanning; + j += sizeof(uint8_t); + } + + if (!lastsectupdate[i] || sector[i].visibility != netsect[i].visibility) + { + *flags |= NET_SECTOR_VISIBILITY; + *(uint8_t *)&pbuf[j] = sector[i].visibility; + j += sizeof(uint8_t); + } + + if (!lastsectupdate[i] || sector[i].lotag != netsect[i].lotag) + { + *flags |= NET_SECTOR_LOTAG; + *(int16_t *)&pbuf[j] = sector[i].lotag; + j += sizeof(int16_t); + } + + if (!lastsectupdate[i] || sector[i].hitag != netsect[i].hitag) + { + *flags |= NET_SECTOR_HITAG; + *(int16_t *)&pbuf[j] = sector[i].hitag; + j += sizeof(int16_t); + } + + if (!lastsectupdate[i] || sector[i].extra != netsect[i].extra) + { + *flags |= NET_SECTOR_EXTRA; + *(int16_t *)&pbuf[j] = sector[i].extra; + j += sizeof(int16_t); + } + + if (lastsectupdate[i]) + Bmemcpy(&netsect[i], §or[i], sizeof(sectortype)); + + return *flags ? j : 0; +} + + +int32_t Net_UnpackWall(int32_t i, uint8_t *pbuf) +{ + int32_t j = 0; + uint32_t flags = *(uint32_t *)&pbuf[j]; + + j += sizeof(uint32_t); + + if (flags & NET_WALL_X) + { + wall[i].x = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } + + if (flags & NET_WALL_Y) + { + wall[i].y = *(int32_t *)&pbuf[j]; + j += sizeof(int32_t); + } + + if (flags & NET_WALL_POINT2) + { + wall[i].point2 = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_WALL_NEXTWALL) + { + wall[i].nextwall = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_WALL_NEXTSECTOR) + { + wall[i].nextsector = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_WALL_CSTAT) + { + wall[i].cstat = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_WALL_PICNUM) + { + wall[i].picnum = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_WALL_OVERPICNUM) + { + wall[i].overpicnum = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_WALL_SHADE) + { + wall[i].shade = *(int8_t *)&pbuf[j]; + j += sizeof(int8_t); + } + + if (flags & NET_WALL_PAL) + { + wall[i].pal = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_WALL_XREPEAT) + { + wall[i].xrepeat = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_WALL_YREPEAT) + { + wall[i].yrepeat = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_WALL_XPANNING) + { + wall[i].xpanning = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_WALL_YPANNING) + { + wall[i].ypanning = *(uint8_t *)&pbuf[j]; + j += sizeof(uint8_t); + } + + if (flags & NET_WALL_LOTAG) + { + wall[i].lotag = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_WALL_HITAG) + { + wall[i].hitag = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + if (flags & NET_WALL_EXTRA) + { + wall[i].extra = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + } + + return j; +} + +int32_t Net_PackWall(int32_t i, uint8_t *pbuf) +{ + int32_t j = 0; + uint32_t *flags; + static walltype netwall[MAXWALLS]; + + if (lastwallupdate[i] && !Bmemcmp(&wall[i], &netwall[i], sizeof(walltype))) + return 0; + + *(int16_t *)&pbuf[j] = i; + j += sizeof(int16_t); + + flags = (uint32_t *)&pbuf[j]; + *flags = 0; + j += sizeof(uint32_t); + + if (!lastwallupdate[i] || wall[i].x != netwall[i].x) + { + *flags |= NET_WALL_X; + *(int32_t *)&pbuf[j] = wall[i].x; + j += sizeof(int32_t); + } + + if (!lastwallupdate[i] || wall[i].y != netwall[i].y) + { + *flags |= NET_WALL_Y; + *(int32_t *)&pbuf[j] = wall[i].y; + j += sizeof(int32_t); + } + + if (!lastwallupdate[i] || wall[i].point2 != netwall[i].point2) + { + *flags |= NET_WALL_POINT2; + *(int16_t *)&pbuf[j] = wall[i].point2; + j += sizeof(int16_t); + } + + if (!lastwallupdate[i] || wall[i].nextwall != netwall[i].nextwall) + { + *flags |= NET_WALL_NEXTWALL; + *(int16_t *)&pbuf[j] = wall[i].nextwall; + j += sizeof(int16_t); + } + + if (!lastwallupdate[i] || wall[i].nextsector != netwall[i].nextsector) + { + *flags |= NET_WALL_NEXTSECTOR; + *(int16_t *)&pbuf[j] = wall[i].nextsector; + j += sizeof(int16_t); + } + + if (!lastwallupdate[i] || wall[i].cstat != netwall[i].cstat) + { + *flags |= NET_WALL_CSTAT; + *(int16_t *)&pbuf[j] = wall[i].cstat; + j += sizeof(int16_t); + } + + if (!lastwallupdate[i] || wall[i].picnum != netwall[i].picnum) + { + *flags |= NET_WALL_PICNUM; + *(int16_t *)&pbuf[j] = wall[i].picnum; + j += sizeof(int16_t); + } + + if (!lastwallupdate[i] || wall[i].overpicnum != netwall[i].overpicnum) + { + *flags |= NET_WALL_OVERPICNUM; + *(int16_t *)&pbuf[j] = wall[i].overpicnum; + j += sizeof(int16_t); + } + + if (!lastwallupdate[i] || wall[i].shade != netwall[i].shade) + { + *flags |= NET_WALL_SHADE; + *(int8_t *)&pbuf[j] = wall[i].shade; + j += sizeof(int8_t); + } + + if (!lastwallupdate[i] || wall[i].pal != netwall[i].pal) + { + *flags |= NET_WALL_PAL; + *(uint8_t *)&pbuf[j] = wall[i].pal; + j += sizeof(uint8_t); + } + + if (!lastwallupdate[i] || wall[i].xrepeat != netwall[i].xrepeat) + { + *flags |= NET_WALL_XREPEAT; + *(uint8_t *)&pbuf[j] = wall[i].xrepeat; + j += sizeof(uint8_t); + } + + if (!lastwallupdate[i] || wall[i].yrepeat != netwall[i].yrepeat) + { + *flags |= NET_WALL_YREPEAT; + *(uint8_t *)&pbuf[j] = wall[i].yrepeat; + j += sizeof(uint8_t); + } + + if (!lastwallupdate[i] || wall[i].xpanning != netwall[i].xpanning) + { + *flags |= NET_WALL_XPANNING; + *(uint8_t *)&pbuf[j] = wall[i].xpanning; + j += sizeof(uint8_t); + } + + if (!lastwallupdate[i] || wall[i].ypanning != netwall[i].ypanning) + { + *flags |= NET_WALL_YPANNING; + *(uint8_t *)&pbuf[j] = wall[i].ypanning; + j += sizeof(uint8_t); + } + + if (!lastwallupdate[i] || wall[i].lotag != netwall[i].lotag) + { + *flags |= NET_WALL_LOTAG; + *(int16_t *)&pbuf[j] = wall[i].lotag; + j += sizeof(int16_t); + } + + if (!lastwallupdate[i] || wall[i].hitag != netwall[i].hitag) + { + *flags |= NET_WALL_HITAG; + *(int16_t *)&pbuf[j] = wall[i].hitag; + j += sizeof(int16_t); + } + + if (!lastwallupdate[i] || wall[i].extra != netwall[i].extra) + { + *flags |= NET_WALL_EXTRA; + *(int16_t *)&pbuf[j] = wall[i].extra; + j += sizeof(int16_t); + } + + if (lastwallupdate[i]) + Bmemcpy(&netwall[i], &wall[i], sizeof(walltype)); + + return *flags ? j : 0; +} + + void Net_ParseServerPacket(ENetEvent *event) { uint8_t *pbuf = event->packet->data; int32_t packbufleng = event->packet->dataLength; - int16_t i, j, l; + int32_t i, j, l; int32_t other = pbuf[--packbufleng]; input_t *nsyn; @@ -601,44 +1710,48 @@ void Net_ParseServerPacket(ENetEvent *event) if (g_player[i].playerquitflag == 0) continue; - if (i == myconnectindex && !g_player[i].ps->dead_flag) - { - j += offsetof(input_t, filler) + - (sizeof(vec3_t) * 3) + // position and velocity - (sizeof(int16_t) * 3); // ang and horiz - goto process; - } + /* if (i == myconnectindex && !g_player[i].ps->dead_flag) + { + j += offsetof(input_t, filler) + + (sizeof(vec3_t) * 3) + // position and velocity + (sizeof(int16_t) * 3); // ang and horiz + goto process; + } + */ nsyn = (input_t *)&inputfifo[0][0]; - Bmemcpy(&nsyn[i], &pbuf[j], offsetof(input_t, filler)); + if (i != myconnectindex || g_player[i].ps->dead_flag) + Bmemcpy(&nsyn[i], &pbuf[j], offsetof(input_t, filler)); + j += offsetof(input_t, filler); // Bmemcpy(&g_player[i].ps->opos.x, &g_player[i].ps->pos.x, sizeof(vec3_t)); - Bmemcpy(&g_player[i].ps->pos.x, &pbuf[j], sizeof(vec3_t) * 2); - if (g_player[i].ps->cursectnum >= 0 && g_player[i].ps->cursectnum < numsectors) - { - updatesectorz(g_player[i].ps->pos.x, g_player[i].ps->pos.y, g_player[i].ps->pos.z, - &g_player[i].ps->cursectnum); - changespritesect(g_player[i].ps->i, g_player[i].ps->cursectnum); - } +// Bmemcpy(&g_player[i].ps->pos.x, &pbuf[j], sizeof(vec3_t) * 2); + Bmemcpy(&sprite[g_player[i].ps->i], &pbuf[j], sizeof(vec3_t)); sprite[g_player[i].ps->i].z += PHEIGHT; j += sizeof(vec3_t) * 2; - Bmemcpy(&g_player[i].ps->posvel.x, &pbuf[j], sizeof(vec3_t)); + Bmemcpy(&g_player[i].ps->vel.x, &pbuf[j], sizeof(vec3_t)); j += sizeof(vec3_t); - g_player[i].ps->oang = g_player[i].ps->ang; - g_player[i].ps->ang = sprite[g_player[i].ps->i].ang = *(int16_t *)&pbuf[j]; - j += sizeof(int16_t); + if (i != myconnectindex) + { + g_player[i].ps->oang = g_player[i].ps->ang; + g_player[i].ps->ang = sprite[g_player[i].ps->i].ang = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); - Bmemcpy(&g_player[i].ps->ohoriz, &g_player[i].ps->horiz, sizeof(int16_t) * 2); - Bmemcpy(&g_player[i].ps->horiz, &pbuf[j], sizeof(int16_t) * 2); - j += sizeof(int16_t) * 2; + Bmemcpy(&g_player[i].ps->ohoriz, &g_player[i].ps->horiz, sizeof(int16_t) * 2); + Bmemcpy(&g_player[i].ps->horiz, &pbuf[j], sizeof(int16_t) * 2); + j += sizeof(int16_t) * 2; + } + else j += sizeof(int16_t) * 3; -process: + + +//process: g_player[i].ps->gotweapon = *(uint16_t *)&pbuf[j]; j += sizeof(uint16_t); @@ -679,8 +1792,19 @@ process: g_player[i].ping = *(int16_t *)&pbuf[j]; j += sizeof(int16_t); + g_player[i].ps->newowner = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + + if (g_player[i].ps->newowner == -1 && g_player[i].ps->cursectnum >= 0 && g_player[i].ps->cursectnum < numsectors) + { + updatesectorz(g_player[i].ps->pos.x, g_player[i].ps->pos.y, g_player[i].ps->pos.z, + &g_player[i].ps->cursectnum); + changespritesect(g_player[i].ps->i, g_player[i].ps->cursectnum); + } + sprite[g_player[i].ps->i].pal = (uint8_t)pbuf[j++]; + l = i; i = g_player[l].ps->i; @@ -726,13 +1850,21 @@ process: { // sprite/sector/wall updates tacked on to the end of the packet - l = pbuf[j++]; + l = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + +// if (l) initprintf("unpacking %d sprites\n", l); + while (l--) { - int32_t i = *(int16_t *)&pbuf[j]; + int32_t spriteid = *(int16_t *)&pbuf[j]; j += sizeof(int16_t); - j += Net_UnpackSprite(i, &pbuf[j]); +/* + initprintf("unpacking sprite %d at %d/%d\n", spriteid, j, packbufleng); + initprintf("flags: %d\n", *(uint32_t *)&pbuf[j]); +*/ + j += Net_UnpackSprite(spriteid, &pbuf[j]); } } @@ -741,39 +1873,48 @@ process: break; case PACKET_MAP_STREAM: - if (!(g_player[myconnectindex].ps->gm & MODE_GAME) || g_netSync) return; + if (!(g_player[myconnectindex].ps->gm & MODE_GAME) || g_netSync) + return; j = 0; packbufleng = qlz_size_decompressed((char *)&pbuf[1]); - pbuf = (uint8_t *)Bcalloc(1, packbufleng+1); + pbuf = (uint8_t *)Bmalloc(packbufleng); packbufleng = qlz_decompress((char *)&event->packet->data[1], (char *)(pbuf), state_decompress); - l = pbuf[j++]; + l = *(uint16_t *)&pbuf[j]; + j += sizeof(uint16_t); + +// if (l) initprintf("unpacking %d sprites\n", l); + while (l--) { - int32_t i = *(int16_t *)&pbuf[j]; + int32_t spriteid = *(int16_t *)&pbuf[j]; j += sizeof(int16_t); - - j += Net_UnpackSprite(i, &pbuf[j]); +// initprintf("unpacking msprite %d at %d/%d\n", spriteid, j, packbufleng); + j += Net_UnpackSprite(spriteid, &pbuf[j]); } - l = pbuf[j++]; + l = *(uint16_t *)&pbuf[j]; + j += sizeof(uint16_t); + while (l--) { int16_t secid = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); - Bmemcpy(§or[secid], &pbuf[j + sizeof(int16_t)], sizeof(sectortype)); - j += sizeof(int16_t) + sizeof(sectortype); + j += Net_UnpackSect(secid, &pbuf[j]); } - l = pbuf[j++]; + l = *(uint16_t *)&pbuf[j]; + j += sizeof(uint16_t); while (l--) { int16_t wallid = *(int16_t *)&pbuf[j]; + j += sizeof(int16_t); + + j += Net_UnpackWall(wallid, &pbuf[j]); - Bmemcpy(&wall[wallid], &pbuf[j + sizeof(int16_t)], sizeof(walltype)); - j += sizeof(int16_t) + sizeof(walltype); // we call dragpoint() to make sure the nextwall position gets updated too dragpoint(wallid, wall[wallid].x, wall[wallid].y); } @@ -819,7 +1960,22 @@ process: G_NewGame(ud.volume_number,ud.level_number,ud.player_skill); ud.coop = ud.m_coop; - if (G_EnterLevel(MODE_GAME)) G_BackToMenu(); + if (G_EnterLevel(MODE_GAME)) + { + G_BackToMenu(); + break; + } + + if (g_netSync) + { + packbuf[0] = PACKET_PLAYER_READY; + packbuf[1] = myconnectindex; + + if (g_netClientPeer) + enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(packbuf, 2, ENET_PACKET_FLAG_RELIABLE)); + g_netSync = 0; + } + break; case PACKET_VERSION: @@ -846,6 +2002,9 @@ process: if (!g_player[pbuf[4]].sync) g_player[pbuf[4]].sync = (input_t *) Bcalloc(1,sizeof(input_t)); } + if (pbuf[5] == NET_DEDICATED_SERVER) + g_networkMode = NET_DEDICATED_CLIENT; + for (i=0; igm & MODE_GAME) || g_netSync) break; + P_ResetPlayer(pbuf[1]); + Bmemcpy(&g_player[pbuf[1]].ps->pos.x, &pbuf[2], sizeof(vec3_t) * 2); + Bmemcpy(&sprite[g_player[pbuf[1]].ps->i], &pbuf[2], sizeof(vec3_t)); break; - case PACKET_PLAYER_READY: - g_player[0].playerreadyflag++; + case PACKET_PLAYER_PING: + g_player[0].pingcnt++; return; case PACKET_FRAG: @@ -1027,15 +2189,16 @@ void Net_ParseClientPacket(ENetEvent *event) g_player[other].playerquitflag = 1; // Bmemcpy(&g_player[other].ps->opos.x, &g_player[other].ps->pos.x, sizeof(vec3_t)); - Bmemcpy(&g_player[other].ps->pos.x, &pbuf[j], sizeof(vec3_t) * 2); - updatesectorz(g_player[other].ps->pos.x, g_player[other].ps->pos.y, g_player[other].ps->pos.z, - &g_player[other].ps->cursectnum); - Bmemcpy(&sprite[g_player[other].ps->i], &pbuf[j], sizeof(vec3_t)); - sprite[g_player[other].ps->i].z += PHEIGHT; - changespritesect(g_player[other].ps->i, g_player[other].ps->cursectnum); +// Bmemcpy(&g_player[other].ps->pos.x, &pbuf[j], sizeof(vec3_t) * 2); +// updatesectorz(g_player[other].ps->pos.x, g_player[other].ps->pos.y, g_player[other].ps->pos.z, +// &g_player[other].ps->cursectnum); +// Bmemcpy(&sprite[g_player[other].ps->i], &pbuf[j], sizeof(vec3_t)); +// sprite[g_player[other].ps->i].z += PHEIGHT; +// changespritesect(g_player[other].ps->i, g_player[other].ps->cursectnum); +// Bmemcpy(&g_player[other].ps->npos.x, &pbuf[j], sizeof(vec3_t)); j += sizeof(vec3_t) * 2; - Bmemcpy(&g_player[other].ps->posvel.x, &pbuf[j], sizeof(vec3_t)); +// Bmemcpy(&g_player[other].ps->vel.x, &pbuf[j], sizeof(vec3_t)); j += sizeof(vec3_t); g_player[other].ps->oang = g_player[other].ps->ang; @@ -1051,13 +2214,40 @@ void Net_ParseClientPacket(ENetEvent *event) break; case PACKET_PLAYER_READY: + j = g_player[other].ps->i; + Bmemcpy(g_player[other].ps, g_player[0].ps, sizeof(DukePlayer_t)); + + g_player[other].ps->i = j; + changespritestat(j, STAT_PLAYER); + + g_player[other].ps->last_extra = sprite[g_player[other].ps->i].extra = g_player[other].ps->max_player_health; + sprite[g_player[other].ps->i].cstat = 1+256; + actor[g_player[other].ps->i].t_data[2] = actor[g_player[other].ps->i].t_data[3] = actor[g_player[other].ps->i].t_data[4] = 0; + + P_ResetPlayer(other); + + j = 0; + packbuf[j++] = PACKET_PLAYER_SPAWN; + packbuf[j++] = other; + + Bmemcpy(&packbuf[j], &g_player[other].ps->pos.x, sizeof(vec3_t) * 2); + j += sizeof(vec3_t) * 2; + + packbuf[j++] = 0; + + enet_host_broadcast(g_netServer, CHAN_GAMESTATE , enet_packet_create(packbuf, j, ENET_PACKET_FLAG_RELIABLE)); + + break; + + + case PACKET_PLAYER_PING: if (g_player[myconnectindex].ps->gm & MODE_GAME) { - packbuf[0] = PACKET_PLAYER_READY; + packbuf[0] = PACKET_PLAYER_PING; packbuf[1] = myconnectindex; enet_peer_send(event->peer, CHAN_GAMESTATE, enet_packet_create(packbuf, 2, ENET_PACKET_FLAG_RELIABLE)); } - g_player[other].playerreadyflag++; + g_player[other].pingcnt++; return; case PACKET_MESSAGE: @@ -1226,19 +2416,11 @@ void Net_ParseClientPacket(ENetEvent *event) enet_peer_send(event->peer, CHAN_GAMESTATE, enet_packet_create(packbuf, 13, ENET_PACKET_FLAG_RELIABLE)); - j = g_player[other].ps->i; - Bmemcpy(g_player[other].ps, g_player[0].ps, sizeof(DukePlayer_t)); - - g_player[other].ps->i = j; - changespritestat(j, STAT_PLAYER); - +/* P_ResetStatus(other); P_ResetWeapons(other); P_ResetInventory(other); - - g_player[other].ps->last_extra = sprite[g_player[other].ps->i].extra = g_player[other].ps->max_player_health; - sprite[g_player[other].ps->i].cstat = 1+256; - actor[g_player[other].ps->i].t_data[2] = actor[g_player[other].ps->i].t_data[3] = actor[g_player[other].ps->i].t_data[4] = 0; +*/ g_netPlayersWaiting--; @@ -1395,15 +2577,26 @@ void Net_GetPackets(void) if (buf && event.packet->dataLength == SYNCPACKETSIZE) { + char tbuf[64]; Bmemcpy((uint8_t *)(buf)+datasiz, event.packet->data, event.packet->dataLength); datasiz += SYNCPACKETSIZE; + + rotatesprite(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64,0,0,xdim-1,ydim-1); + + rotatesprite(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); + rotatesprite(160<<16,(129)<<16,30<<11,0,THREEDEE,0,0,2+8,0,0,xdim-1,ydim-1); + if (PLUTOPAK) // JBF 20030804 + rotatesprite(160<<16,(151)<<16,30<<11,0,PLUTOPAKSPRITE+1,0,0,2+8,0,0,xdim-1,ydim-1); + + Bsprintf(tbuf, "RECEIVED %d BYTES\n", datasiz); + gametext(160,190,tbuf,14,2); } // last packet of mapstate sequence else if (buf) { Bmemcpy((uint8_t *)(buf)+datasiz, event.packet->data, event.packet->dataLength); datasiz = 0; - g_netSync = 0; +// g_netSync = 0; if (qlz_size_decompressed((const char *)buf) == sizeof(mapstate_t)) { @@ -1414,6 +2607,15 @@ void Net_GetPackets(void) packbuf[0] = PACKET_REQUEST_GAMESTATE; packbuf[1] = myconnectindex; enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(&packbuf[0], 2, ENET_PACKET_FLAG_RELIABLE)); + + rotatesprite(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64,0,0,xdim-1,ydim-1); + + rotatesprite(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); + rotatesprite(160<<16,(129)<<16,30<<11,0,THREEDEE,0,0,2+8,0,0,xdim-1,ydim-1); + if (PLUTOPAK) // JBF 20030804 + rotatesprite(160<<16,(151)<<16,30<<11,0,PLUTOPAKSPRITE+1,0,0,2+8,0,0,xdim-1,ydim-1); + + gametext(160,190,"TRANSFER COMPLETE",14,2); } else { @@ -1421,6 +2623,15 @@ void Net_GetPackets(void) Bfree(buf); buf = NULL; g_netDisconnect = 1; + + rotatesprite(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64,0,0,xdim-1,ydim-1); + + rotatesprite(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); + rotatesprite(160<<16,(129)<<16,30<<11,0,THREEDEE,0,0,2+8,0,0,xdim-1,ydim-1); + if (PLUTOPAK) // JBF 20030804 + rotatesprite(160<<16,(151)<<16,30<<11,0,PLUTOPAKSPRITE+1,0,0,2+8,0,0,xdim-1,ydim-1); + + gametext(160,190,"TRANSFER ERROR",14,2); } } else @@ -1428,6 +2639,8 @@ void Net_GetPackets(void) initprintf("Error allocating buffer for map state!\n"); g_netDisconnect = 1; } + + nextpage(); } else Net_ParseServerPacket(&event); @@ -1448,7 +2661,7 @@ void Net_GetPackets(void) initprintf("You have been kicked from the server.\n"); return; case DISC_BANNED: - initprintf("You have been banned from this server.\n"); + initprintf("You are banned from this server.\n"); return; default: initprintf("Disconnected.\n"); @@ -1461,6 +2674,43 @@ void Net_GetPackets(void) } } +void Net_ClientMove(void) +{ + int32_t j; + input_t *nsyn = (input_t *)&inputfifo[0][myconnectindex]; + + packbuf[0] = PACKET_SLAVE_TO_MASTER; + j = 1; + + Bmemcpy(&packbuf[j], &nsyn[0], offsetof(input_t, filler)); + j += offsetof(input_t, filler); + + Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->pos.x, sizeof(vec3_t) * 2); + j += sizeof(vec3_t) * 2; + + Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->vel.x, sizeof(vec3_t)); + j += sizeof(vec3_t); + + *(int16_t *)&packbuf[j] = g_player[myconnectindex].ps->ang; + j += sizeof(int16_t); + + Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->horiz, sizeof(int16_t) * 2); + j += sizeof(int16_t) * 2; + + { + char buf[1024]; + + j = qlz_compress((char *)(packbuf)+1, (char *)buf, j, state_compress); + Bmemcpy((char *)(packbuf)+1, (char *)buf, j); + j++; + } + + packbuf[j++] = myconnectindex; + + enet_peer_send(g_netClientPeer, CHAN_MOVE, enet_packet_create(packbuf, j, 0)); + +} + void Net_UpdateClients(void) { input_t *osyn = (input_t *)&inputfifo[1][0]; @@ -1500,7 +2750,7 @@ void Net_UpdateClients(void) Bmemcpy(&packbuf[j], &g_player[i].ps->pos.x, sizeof(vec3_t) * 2); j += sizeof(vec3_t) * 2; - Bmemcpy(&packbuf[j], &g_player[i].ps->posvel.x, sizeof(vec3_t)); + Bmemcpy(&packbuf[j], &g_player[i].ps->vel.x, sizeof(vec3_t)); j += sizeof(vec3_t); *(int16_t *)&packbuf[j] = g_player[i].ps->ang; @@ -1547,6 +2797,9 @@ void Net_UpdateClients(void) *(int16_t *)&packbuf[j] = g_player[i].ping; j += sizeof(int16_t); + *(int16_t *)&packbuf[j] = g_player[i].ps->newowner; + j += sizeof(int16_t); + packbuf[j++] = sprite[g_player[i].ps->i].pal; l = i; @@ -1576,7 +2829,7 @@ void Net_UpdateClients(void) { int16_t ii=g_gameVarCount-1, kk = 0; - for (; ii>=0 && kk <= 64; ii--) + for (; ii>=0 && j <= (SYNCPACKETSIZE-(SYNCPACKETSIZE>>3)); ii--) { if ((aGameVars[ii].dwFlags & (GAMEVAR_PERACTOR|GAMEVAR_NOMULTI)) == GAMEVAR_PERACTOR && aGameVars[ii].val.plValues) { @@ -1587,6 +2840,9 @@ void Net_UpdateClients(void) *(int32_t *)&packbuf[j] = aGameVars[ii].val.plValues[i]; j += sizeof(int32_t); kk++; + + if (j >= (SYNCPACKETSIZE-(SYNCPACKETSIZE>>3))) + break; } } } @@ -1599,7 +2855,7 @@ void Net_UpdateClients(void) { int16_t ii=g_gameVarCount-1, kk = 0; - for (; ii>=0 && kk <= 64; ii--) + for (; ii>=0 && j <= (SYNCPACKETSIZE-(SYNCPACKETSIZE>>3)); ii--) { if ((aGameVars[ii].dwFlags & (GAMEVAR_PERPLAYER|GAMEVAR_NOMULTI)) == GAMEVAR_PERPLAYER && aGameVars[ii].val.plValues) { @@ -1610,6 +2866,9 @@ void Net_UpdateClients(void) *(int32_t *)&packbuf[j] = aGameVars[ii].val.plValues[i]; j += sizeof(int32_t); kk++; + + if (j >= (SYNCPACKETSIZE-(SYNCPACKETSIZE>>3))) + break; } } } @@ -1623,23 +2882,29 @@ void Net_UpdateClients(void) { int32_t zz, zj; - packbuf[(zj = j++)] = 0; + packbuf[(zj = j)] = 0; + j += sizeof(int16_t); - for (zz = 0; (unsigned)zz < (sizeof(g_netStatnums)/sizeof(g_netStatnums[0])) /*&& k <= 3*/; zz++) + for (zz = 0; (unsigned)zz < (sizeof(g_netStatnums)/sizeof(g_netStatnums[0])) && j <= (SYNCPACKETSIZE-(SYNCPACKETSIZE>>3)); zz++) TRAVERSE_SPRITE_STAT(headspritestat[g_netStatnums[zz]], i, nexti) { // only send newly spawned sprites - if (!lastupdate[i]) + if (!lastupdate[i] && sprite[i].statnum != MAXSTATUS) { + int32_t ii; + + j += (ii = Net_PackSprite(i, (uint8_t *)&packbuf[j])); + if (ii) k++; + lastupdate[i] = totalclock; - j += Net_PackSprite(i, (uint8_t *)&packbuf[j]); - k++; + if (j >= (SYNCPACKETSIZE-(SYNCPACKETSIZE>>3))) + break; } } - packbuf[zj] = k; - j++; + *(int16_t *)&packbuf[zj] = k; + j += sizeof(int16_t); } { @@ -1662,19 +2927,19 @@ void Net_UpdateClients(void) void Net_StreamLevel(void) { - int16_t i, nexti, k = 0, l; - int32_t j; - int32_t zz, zj; + int16_t i, nexti; + int32_t j = 0; + int32_t zz, zj, k = 0, l; if (!g_netServer || numplayers < 2) return; - packbuf[0] = PACKET_MAP_STREAM; - j = 1; + packbuf[j++] = PACKET_MAP_STREAM; - packbuf[(zj = j++)] = 0; + *(uint16_t *)&packbuf[(zj = j)] = 0; + j += sizeof(uint16_t); - for (zz = 0; (unsigned)zz < (sizeof(g_netStatnums)/sizeof(g_netStatnums[0])) /*&& k <= 3*/; zz++) + for (zz = 0; (unsigned)zz < (sizeof(g_netStatnums)/sizeof(g_netStatnums[0])) && j <= (SYNCPACKETSIZE-(SYNCPACKETSIZE>>3)); zz++) TRAVERSE_SPRITE_STAT(headspritestat[g_netStatnums[zz]], i, nexti) { // only send STAT_MISC sprites at spawn time and let the client handle it from there @@ -1684,21 +2949,30 @@ void Net_StreamLevel(void) if (!lastupdate[i] || spritecrc[i] != l) { + int32_t ii; /*initprintf("updating sprite %d (%d)\n",i,sprite[i].picnum);*/ spritecrc[i] = l; + + j += (ii = Net_PackSprite(i, (uint8_t *)&packbuf[j])); + if (ii) k++; + lastupdate[i] = totalclock; - j += Net_PackSprite(i, (uint8_t *)&packbuf[j]); - k++; + if (j >= (SYNCPACKETSIZE-(SYNCPACKETSIZE>>3))) + break; } } } - packbuf[zj] = k; + *(uint16_t *)&packbuf[zj] = k; +// j += sizeof(uint16_t); + k = 0; - packbuf[(zj = j++)] = 0; - for (i = numsectors-1; i >= 0 && k <= 6; i--) + *(uint16_t *)&packbuf[(zj = j)] = 0; + j += sizeof(uint16_t); + + for (i = numsectors-1; i >= 0 && j <= (SYNCPACKETSIZE-(SYNCPACKETSIZE>>3)); i--) { if (totalclock > (lastsectupdate[i] + TICRATE)) { @@ -1708,19 +2982,22 @@ void Net_StreamLevel(void) { sectcrc[i] = l; lastsectupdate[i] = totalclock; - *(int16_t *)&packbuf[j] = i; - j += sizeof(int16_t); - Bmemcpy(&packbuf[j], §or[i], sizeof(sectortype)); - j += sizeof(sectortype); + j += Net_PackSect(i, (uint8_t *)&packbuf[j]); k++; + + if (j >= (SYNCPACKETSIZE-(SYNCPACKETSIZE>>3))) + break; } } } - packbuf[zj] = k; + *(uint16_t *)&packbuf[zj] = k; +// j += sizeof(uint16_t); k = 0; - packbuf[(zj = j++)] = 0; - for (i = numwalls-1; i >= 0 && k <= 6; i--) + *(uint16_t *)&packbuf[(zj = j)] = 0; + j += sizeof(uint16_t); + + for (i = numwalls-1; i >= 0 && j <= (SYNCPACKETSIZE-(SYNCPACKETSIZE>>3)); i--) { if (totalclock > (lastwallupdate[i] + TICRATE)) { @@ -1730,17 +3007,16 @@ void Net_StreamLevel(void) { wallcrc[i] = l; lastwallupdate[i] = totalclock; - *(int16_t *)&packbuf[j] = i; - j += sizeof(int16_t); - Bmemcpy(&packbuf[j], &wall[i], sizeof(walltype)); - j += sizeof(walltype); + j += Net_PackWall(i, (uint8_t *)&packbuf[j]); k++; + + if (j >= (SYNCPACKETSIZE-(SYNCPACKETSIZE>>3))) + break; } } } - packbuf[zj] = k; - - j++; + *(uint16_t *)&packbuf[zj] = k; +// j += sizeof(uint16_t); { char buf[PACKBUF_SIZE]; @@ -1762,10 +3038,9 @@ void Net_StreamLevel(void) void faketimerhandler(void) { - if (g_netServer) - enet_host_service(g_netServer, NULL, 0); - else if (g_netClient) - enet_host_service(g_netClient, NULL, 0); + if (((uintptr_t)g_netServer|(uintptr_t)g_netClient) == (uintptr_t)NULL) return; + + enet_host_service(g_netServer ? g_netServer : g_netClient, NULL, 0); } void Net_EnterMessage(void) @@ -1922,29 +3197,27 @@ void Net_EnterMessage(void) void Net_WaitForServer(void) { - int32_t server_ready = g_player[0].playerreadyflag; + int32_t server_ready = g_player[0].pingcnt; if (numplayers < 2 || g_netServer) return; - if ((g_netServer || ud.multimode > 1)) - { - P_SetGamePalette(g_player[myconnectindex].ps, TITLEPAL, 11); - rotatesprite(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64,0,0,xdim-1,ydim-1); + P_SetGamePalette(g_player[myconnectindex].ps, TITLEPAL, 11); - rotatesprite(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); - rotatesprite(160<<16,(129)<<16,30<<11,0,THREEDEE,0,0,2+8,0,0,xdim-1,ydim-1); - if (PLUTOPAK) // JBF 20030804 - rotatesprite(160<<16,(151)<<16,30<<11,0,PLUTOPAKSPRITE+1,0,0,2+8,0,0,xdim-1,ydim-1); + rotatesprite(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64,0,0,xdim-1,ydim-1); - gametext(160,190,"WAITING FOR SERVER",14,2); - nextpage(); - } + rotatesprite(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); + rotatesprite(160<<16,(129)<<16,30<<11,0,THREEDEE,0,0,2+8,0,0,xdim-1,ydim-1); + if (PLUTOPAK) // JBF 20030804 + rotatesprite(160<<16,(151)<<16,30<<11,0,PLUTOPAKSPRITE+1,0,0,2+8,0,0,xdim-1,ydim-1); + + gametext(160,170,"WAITING FOR SERVER",14,2); + nextpage(); do { if (quitevent || keystatus[1]) G_GameExit(""); - packbuf[0] = PACKET_PLAYER_READY; + packbuf[0] = PACKET_PLAYER_PING; packbuf[1] = myconnectindex; if (g_netClientPeer) @@ -1953,7 +3226,7 @@ void Net_WaitForServer(void) handleevents(); Net_GetPackets(); - if (g_player[0].playerreadyflag > server_ready) + if (g_player[0].pingcnt > server_ready) { P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 11); return; diff --git a/polymer-perf/eduke32/source/net.h b/polymer-perf/eduke32/source/net.h index 1879e03ff..36f5cc8d9 100644 --- a/polymer-perf/eduke32/source/net.h +++ b/polymer-perf/eduke32/source/net.h @@ -25,6 +25,92 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "enet/enet.h" +#define NET_SECTOR_WALLPTR 0x00000001 +#define NET_SECTOR_WALLNUM 0x00000002 +#define NET_SECTOR_CEILINGZ 0x00000004 +#define NET_SECTOR_FLOORZ 0x00000008 +#define NET_SECTOR_CEILINGSTAT 0x00000010 +#define NET_SECTOR_FLOORSTAT 0x00000020 +#define NET_SECTOR_CEILINGPIC 0x00000040 +#define NET_SECTOR_CEILINGSLOPE 0x00000080 +#define NET_SECTOR_CEILINGSHADE 0x00000100 +#define NET_SECTOR_CEILINGPAL 0x00000200 +#define NET_SECTOR_CEILINGXPAN 0x00000400 +#define NET_SECTOR_CEILINGYPAN 0x00000800 +#define NET_SECTOR_FLOORPIC 0x00001000 +#define NET_SECTOR_FLOORSLOPE 0x00002000 +#define NET_SECTOR_FLOORSHADE 0x00004000 +#define NET_SECTOR_FLOORPAL 0x00008000 +#define NET_SECTOR_FLOORXPAN 0x00010000 +#define NET_SECTOR_FLOORYPAN 0x00020000 +#define NET_SECTOR_VISIBILITY 0x00040000 +#define NET_SECTOR_LOTAG 0x00080000 +#define NET_SECTOR_HITAG 0x00100000 +#define NET_SECTOR_EXTRA 0x00200000 + +#define NET_WALL_X 0x00000001 +#define NET_WALL_Y 0x00000002 +#define NET_WALL_POINT2 0x00000004 +#define NET_WALL_NEXTWALL 0x00000008 +#define NET_WALL_NEXTSECTOR 0x00000010 +#define NET_WALL_CSTAT 0x00000020 +#define NET_WALL_PICNUM 0x00000040 +#define NET_WALL_OVERPICNUM 0x00000080 +#define NET_WALL_SHADE 0x00000100 +#define NET_WALL_PAL 0x00000200 +#define NET_WALL_XREPEAT 0x00000400 +#define NET_WALL_YREPEAT 0x00000800 +#define NET_WALL_XPANNING 0x00001000 +#define NET_WALL_YPANNING 0x00002000 +#define NET_WALL_LOTAG 0x00004000 +#define NET_WALL_HITAG 0x00008000 +#define NET_WALL_EXTRA 0x00010000 + +#define NET_SPRITE_X 0x00000001 +#define NET_SPRITE_Y 0x00000002 +#define NET_SPRITE_Z 0x00000004 +#define NET_SPRITE_SHADE 0x00000008 +#define NET_SPRITE_PAL 0x00000010 +#define NET_SPRITE_CLIPDIST 0x00000020 +#define NET_SPRITE_XREPEAT 0x00000040 +#define NET_SPRITE_YREPEAT 0x00000080 +#define NET_SPRITE_XOFFSET 0x00000100 +#define NET_SPRITE_YOFFSET 0x00000200 +#define NET_SPRITE_SECTNUM 0x00000400 +#define NET_SPRITE_STATNUM 0x00000800 +#define NET_SPRITE_ANG 0x00001000 +#define NET_SPRITE_OWNER 0x00002000 +#define NET_SPRITE_XVEL 0x00004000 +#define NET_SPRITE_YVEL 0x00008000 +#define NET_SPRITE_ZVEL 0x00010000 +#define NET_SPRITE_LOTAG 0x00020000 +#define NET_SPRITE_HITAG 0x00040000 +#define NET_SPRITE_EXTRA 0x00080000 +#define NET_SPRITE_CSTAT 0x00100000 +#define NET_SPRITE_PICNUM 0x00200000 + +#define NET_ACTOR_T1 0x00000001 +#define NET_ACTOR_T2 0x00000002 +#define NET_ACTOR_T3 0x00000004 +#define NET_ACTOR_T4 0x00000008 +#define NET_ACTOR_T5 0x00000010 +#define NET_ACTOR_T6 0x00000020 +#define NET_ACTOR_T7 0x00000040 +#define NET_ACTOR_T8 0x00000080 +#define NET_ACTOR_T9 0x00000100 +#define NET_ACTOR_T10 0x00000200 +#define NET_ACTOR_PICNUM 0x00000400 +#define NET_ACTOR_ANG 0x00000800 +#define NET_ACTOR_EXTRA 0x00001000 +#define NET_ACTOR_OWNER 0x00002000 +#define NET_ACTOR_MOVFLAG 0x00004000 +#define NET_ACTOR_TEMPANG 0x00008000 +#define NET_ACTOR_TIMETOSLEEP 0x00010000 +#define NET_ACTOR_FLAGS 0x00020000 +#define NET_ACTOR_PTR1 0x00040000 +#define NET_ACTOR_PTR2 0x00080000 +#define NET_ACTOR_PTR3 0x00100000 + enum netchan_t { CHAN_MOVE, // unreliable movement packets @@ -48,6 +134,7 @@ enum DukePacket_t PACKET_REQUEST_GAMESTATE, PACKET_VERSION, PACKET_AUTH, + PACKET_PLAYER_PING, PACKET_PLAYER_READY, PACKET_MAP_STREAM, @@ -69,13 +156,21 @@ enum DukePacket_t PACKET_MAP_VOTE_CANCEL, }; -enum NetDisconnect_t +enum netdisconnect_t { DISC_BAD_PASSWORD = 1, DISC_KICKED, DISC_BANNED }; +enum netmode_t +{ + NET_CLIENT = 0, + NET_SERVER, + NET_DEDICATED_CLIENT, // client on dedicated server + NET_DEDICATED_SERVER +}; + extern ENetHost *g_netClient; extern ENetHost *g_netServer; extern ENetPeer *g_netClientPeer; @@ -83,16 +178,17 @@ extern char g_netPassword[32]; extern int32_t g_netDisconnect; extern int32_t g_netPlayersWaiting; extern int32_t g_netPort; -extern int32_t g_netServerMode; +extern int32_t g_networkMode; extern int32_t g_netSync; extern int32_t lastsectupdate[MAXSECTORS]; extern int32_t lastupdate[MAXSPRITES]; extern int32_t lastwallupdate[MAXWALLS]; -extern int8_t g_netStatnums[8]; +extern int16_t g_netStatnums[10]; extern mapstate_t *g_multiMapState; int32_t Net_PackSprite(int32_t i,uint8_t *pbuf); int32_t Net_UnpackSprite(int32_t i,uint8_t *pbuf); +void Net_ClientMove(void); void Net_Connect(const char *srvaddr); void Net_Disconnect(void); void Net_EnterMessage(void); diff --git a/polymer-perf/eduke32/source/osdcmds.c b/polymer-perf/eduke32/source/osdcmds.c index 112e96a2f..1001c0206 100644 --- a/polymer-perf/eduke32/source/osdcmds.c +++ b/polymer-perf/eduke32/source/osdcmds.c @@ -1165,7 +1165,7 @@ static int32_t osdcmd_listplayers(const osdfuncparm_t *parm) ENetPeer *currentPeer; char ipaddr[32]; - if (parm->numparms != 0) + if (parm && parm->numparms != 0) return OSDCMD_SHOWHELP; if (!g_netServer) @@ -1174,6 +1174,8 @@ static int32_t osdcmd_listplayers(const osdfuncparm_t *parm) return OSDCMD_OK; } + initprintf("Connected clients:\n"); + for (currentPeer = g_netServer -> peers; currentPeer < & g_netServer -> peers [g_netServer -> peerCount]; ++ currentPeer) @@ -1222,6 +1224,7 @@ static int32_t osdcmd_kick(const osdfuncparm_t *parm) } initprintf("Player %s not found!\n", parm->parms[0]); + osdcmd_listplayers(NULL); return OSDCMD_OK; } @@ -1264,6 +1267,7 @@ static int32_t osdcmd_kickban(const osdfuncparm_t *parm) } initprintf("Player %s not found!\n", parm->parms[0]); + osdcmd_listplayers(NULL); return OSDCMD_OK; } diff --git a/polymer-perf/eduke32/source/osdfuncs.c b/polymer-perf/eduke32/source/osdfuncs.c index 729f6dd96..9aa37500b 100644 --- a/polymer-perf/eduke32/source/osdfuncs.c +++ b/polymer-perf/eduke32/source/osdfuncs.c @@ -31,7 +31,7 @@ int32_t osdhightile = 0; void GAME_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, int32_t pal) { int16_t ac; -#if !defined(POLYMOST) || !defined(USE_OPENGL) +#ifndef USE_OPENGL int32_t usehightile = 0; #endif int32_t ht = usehightile; @@ -49,7 +49,7 @@ void GAME_drawosdstr(int32_t x, int32_t y, char *ch, int32_t len, int32_t shade, int16_t ac; char *ptr = OSD_GetTextPtr(); char *fmt = OSD_GetFmtPtr(); -#if !defined(POLYMOST) || !defined(USE_OPENGL) +#ifndef USE_OPENGL int32_t usehightile = 0; #endif int32_t ht = usehightile; diff --git a/polymer-perf/eduke32/source/player.c b/polymer-perf/eduke32/source/player.c index cf40117be..5d4dffdd3 100644 --- a/polymer-perf/eduke32/source/player.c +++ b/polymer-perf/eduke32/source/player.c @@ -2007,7 +2007,7 @@ static void G_DrawTileScaled(int32_t x, int32_t y, int32_t tilenum, int32_t shad if (orientation&4) a = 1024; -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL if (getrendermode() >= 3 && usemodels && md_tilehasmodel(tilenum,p) > 0) y += (224-weapsc(224)); #endif @@ -2958,7 +2958,7 @@ void P_DisplayWeapon(int32_t snum) int32_t g_myAimMode = 0, g_myAimStat = 0, g_oldAimStat = 0; int32_t mouseyaxismode = -1; -int32_t jump_timer = 0; +int32_t g_emuJumpTics = 0; void getinput(int32_t snum) { @@ -2996,7 +2996,7 @@ void getinput(int32_t snum) if (g_myAimStat > g_oldAimStat) { g_myAimMode ^= 1; - P_DoQuote(44+g_myAimMode,p); + P_DoQuote(QUOTE_MOUSE_AIMING_OFF+g_myAimMode,p); } } @@ -3166,12 +3166,12 @@ void getinput(int32_t snum) j = 12; if (BUTTON(gamefunc_Jump) && p->on_ground) - jump_timer = 4; + g_emuJumpTics = 4; - loc.bits = (jump_timer > 0 || BUTTON(gamefunc_Jump))< 0 || BUTTON(gamefunc_Jump))< 0) - jump_timer--; + if (g_emuJumpTics > 0) + g_emuJumpTics--; loc.bits |= BUTTON(gamefunc_Crouch)<scuba_on = 1; p->inven_icon = 6; - P_DoQuote(76,p); + P_DoQuote(QUOTE_SCUBA_ON,p); } else { @@ -3665,8 +3665,8 @@ void P_CheckTouchDamage(DukePlayer_t *p,int32_t j) p->pals.g = 0; p->pals.b = 0; - p->posvel.x = -(sintable[(p->ang+512)&2047]<<8); - p->posvel.y = -(sintable[(p->ang)&2047]<<8); + p->vel.x = -(sintable[(p->ang+512)&2047]<<8); + p->vel.y = -(sintable[(p->ang)&2047]<<8); A_PlaySound(DUKE_LONGTERM_PAIN,p->i); { @@ -3848,13 +3848,13 @@ void P_FragPlayer(int32_t snum) if (snum == screenpeek) { - Bsprintf(ScriptQuotes[115],"KILLED BY %s",&g_player[p->frag_ps].user_name[0]); - P_DoQuote(115,p); + Bsprintf(ScriptQuotes[QUOTE_RESERVED],"KILLED BY %s",&g_player[p->frag_ps].user_name[0]); + P_DoQuote(QUOTE_RESERVED,p); } else { - Bsprintf(ScriptQuotes[116],"KILLED %s",&g_player[snum].user_name[0]); - P_DoQuote(116,g_player[p->frag_ps].ps); + Bsprintf(ScriptQuotes[QUOTE_RESERVED2],"KILLED %s",&g_player[snum].user_name[0]); + P_DoQuote(QUOTE_RESERVED2,g_player[p->frag_ps].ps); } if (ud.obituaries) @@ -3941,13 +3941,13 @@ void P_ProcessWeapon(int32_t snum) { p->holster_weapon = 1; p->weapon_pos = -1; - P_DoQuote(73,p); + P_DoQuote(QUOTE_WEAPON_LOWERED,p); } else if (p->holster_weapon == 1 && p->weapon_pos == -9) { p->holster_weapon = 0; p->weapon_pos = 10; - P_DoQuote(74,p); + P_DoQuote(QUOTE_WEAPON_RAISED,p); } } @@ -4027,7 +4027,7 @@ void P_ProcessWeapon(int32_t snum) { p->holster_weapon = 0; p->weapon_pos = 10; - P_DoQuote(74,p); + P_DoQuote(QUOTE_WEAPON_RAISED,p); } } else @@ -4110,7 +4110,7 @@ void P_ProcessWeapon(int32_t snum) (hitinfo.pos.y-p->pos.y)*(hitinfo.pos.y-p->pos.y)) < (290*290)) { p->pos.z = p->opos.z; - p->posvel.z = 0; + p->vel.z = 0; (*kb) = 1; if (aplWeaponInitialSound[p->curr_weapon][snum] > 0) { @@ -4290,7 +4290,7 @@ void P_ProcessWeapon(int32_t snum) && *kb < (aplWeaponFireDelay[p->curr_weapon][snum]+1)) { p->pos.z = p->opos.z; - p->posvel.z = 0; + p->vel.z = 0; } if (*kb == aplWeaponSound2Time[p->curr_weapon][snum]) @@ -4485,6 +4485,9 @@ void P_ProcessInput(int32_t snum) uint8_t *kb = &p->kickback_pic; int16_t tempsect; + if (g_player[snum].playerquitflag == 0) + return; + p->player_par++; VM_OnEvent(EVENT_PROCESSINPUT, p->i, snum, -1); @@ -4567,8 +4570,8 @@ void P_ProcessInput(int32_t snum) { // I think this is what makes the player slide off enemies... might be a good sprite flag to add later j = getangle(sprite[j].x-p->pos.x,sprite[j].y-p->pos.y); - p->posvel.x -= sintable[(j+512)&2047]<<4; - p->posvel.y -= sintable[j&2047]<<4; + p->vel.x -= sintable[(j+512)&2047]<<4; + p->vel.y -= sintable[j&2047]<<4; } } @@ -4597,7 +4600,7 @@ void P_ProcessInput(int32_t snum) if (p->customexitsound >= 0) { S_PlaySound(p->customexitsound); - P_DoQuote(102,p); + P_DoQuote(QUOTE_WEREGONNAFRYYOURASS,p); } } else if (p->timebeforeexit == 1) @@ -4689,7 +4692,7 @@ void P_ProcessInput(int32_t snum) p->pos.y = SY; p->pos.z = SZ; p->ang = SA; - p->posvel.x = p->posvel.y = s->xvel = 0; + p->vel.x = p->vel.y = s->xvel = 0; p->look_ang = 0; p->rotscrnang = 0; @@ -4802,9 +4805,9 @@ void P_ProcessInput(int32_t snum) if (aGameVars[g_iReturnVarID].val.lValue == 0) { // jump - if (p->posvel.z > 0) p->posvel.z = 0; - p->posvel.z -= 348; - if (p->posvel.z < -(256*6)) p->posvel.z = -(256*6); + if (p->vel.z > 0) p->vel.z = 0; + p->vel.z -= 348; + if (p->vel.z < -(256*6)) p->vel.z = -(256*6); } } else if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) @@ -4814,32 +4817,32 @@ void P_ProcessInput(int32_t snum) if (aGameVars[g_iReturnVarID].val.lValue == 0) { // crouch - if (p->posvel.z < 0) p->posvel.z = 0; - p->posvel.z += 348; - if (p->posvel.z > (256*6)) p->posvel.z = (256*6); + if (p->vel.z < 0) p->vel.z = 0; + p->vel.z += 348; + if (p->vel.z > (256*6)) p->vel.z = (256*6); } } else { // normal view - if (p->posvel.z < 0) + if (p->vel.z < 0) { - p->posvel.z += 256; - if (p->posvel.z > 0) - p->posvel.z = 0; + p->vel.z += 256; + if (p->vel.z > 0) + p->vel.z = 0; } - if (p->posvel.z > 0) + if (p->vel.z > 0) { - p->posvel.z -= 256; - if (p->posvel.z < 0) - p->posvel.z = 0; + p->vel.z -= 256; + if (p->vel.z < 0) + p->vel.z = 0; } } - if (p->posvel.z > 2048) - p->posvel.z >>= 1; + if (p->vel.z > 2048) + p->vel.z >>= 1; - p->pos.z += p->posvel.z; + p->pos.z += p->vel.z; if (p->pos.z > (fz-(15<<8))) p->pos.z += ((fz-(15<<8))-p->pos.z)>>1; @@ -4847,7 +4850,7 @@ void P_ProcessInput(int32_t snum) if (p->pos.z < cz) { p->pos.z = cz; - p->posvel.z = 0; + p->vel.z = 0; } if (p->scuba_on && (krand()&255) < 8) @@ -5004,16 +5007,16 @@ void P_ProcessInput(int32_t snum) else { p->on_ground = 0; - p->posvel.z += (g_spriteGravity+80); // (TICSPERFRAME<<6); - if (p->posvel.z >= (4096+2048)) p->posvel.z = (4096+2048); - if (p->posvel.z > 2400 && p->falling_counter < 255) + p->vel.z += (g_spriteGravity+80); // (TICSPERFRAME<<6); + if (p->vel.z >= (4096+2048)) p->vel.z = (4096+2048); + if (p->vel.z > 2400 && p->falling_counter < 255) { p->falling_counter++; if (p->falling_counter >= 38 && p->scream_voice <= FX_Ok) p->scream_voice = A_PlaySound(DUKE_SCREAM,p->i); } - if ((p->pos.z+p->posvel.z) >= (fz-(i<<8)) && p->cursectnum >= 0) // hit the ground + if ((p->pos.z+p->vel.z) >= (fz-(i<<8)) && p->cursectnum >= 0) // hit the ground if (sector[p->cursectnum].lotag != 1) { if (p->falling_counter > 62) @@ -5040,7 +5043,7 @@ void P_ProcessInput(int32_t snum) p->pals.b = 0; p->pals.f = 32; } - else if (p->posvel.z > 2048) + else if (p->vel.z > 2048) A_PlaySound(DUKE_LAND,p->i); } } @@ -5057,8 +5060,8 @@ void P_ProcessInput(int32_t snum) p->scream_voice = -1; } - if (psectlotag != 1 && psectlotag != 2 && p->on_ground == 0 && p->posvel.z > (6144>>1)) - p->hard_landing = p->posvel.z>>10; + if (psectlotag != 1 && psectlotag != 2 && p->on_ground == 0 && p->vel.z > (6144>>1)) + p->hard_landing = p->vel.z>>10; p->on_ground = 1; @@ -5069,8 +5072,8 @@ void P_ProcessInput(int32_t snum) k = ((fz-(i<<8))-p->pos.z)>>1; if (klabs(k) < 256) k = 0; p->pos.z += k; - p->posvel.z -= 768; - if (p->posvel.z < 0) p->posvel.z = 0; + p->vel.z -= 768; + if (p->vel.z < 0) p->vel.z = 0; } else if (p->jumping_counter == 0) { @@ -5078,7 +5081,7 @@ void P_ProcessInput(int32_t snum) if (p->on_warping_sector == 0 && p->pos.z > fz-(16<<8)) { p->pos.z = fz-(16<<8); - p->posvel.z >>= 1; + p->vel.z >>= 1; } } @@ -5128,11 +5131,11 @@ void P_ProcessInput(int32_t snum) if (psectlotag == 1 && p->jumping_counter > 768) { p->jumping_counter = 0; - p->posvel.z = -512; + p->vel.z = -512; } else { - p->posvel.z -= (sintable[(2048-128+p->jumping_counter)&2047])/12; + p->vel.z -= (sintable[(2048-128+p->jumping_counter)&2047])/12; p->jumping_counter += 180; p->on_ground = 0; } @@ -5140,18 +5143,18 @@ void P_ProcessInput(int32_t snum) else { p->jumping_counter = 0; - p->posvel.z = 0; + p->vel.z = 0; } } - p->pos.z += p->posvel.z; + p->pos.z += p->vel.z; if ((psectlotag != 2 || cz != sector[p->cursectnum].ceilingz) && p->pos.z < (cz+(4<<8))) { p->jumping_counter = 0; - if (p->posvel.z < 0) - p->posvel.x = p->posvel.y = 0; - p->posvel.z = 128; + if (p->vel.z < 0) + p->vel.x = p->vel.y = 0; + p->vel.z = 128; p->pos.z = cz+(4<<8); } } @@ -5161,8 +5164,8 @@ void P_ProcessInput(int32_t snum) *kb > 1 && *kb < *aplWeaponFireDelay[p->curr_weapon])) { doubvel = 0; - p->posvel.x = 0; - p->posvel.y = 0; + p->vel.x = 0; + p->vel.y = 0; } else if (g_player[snum].sync->avel) //p->ang += syncangvel * constant { @@ -5203,7 +5206,7 @@ void P_ProcessInput(int32_t snum) if (p->on_ground && truefdist <= PHEIGHT+(16<<8) && P_CheckFloorDamage(p, j)) { - P_DoQuote(75, p); + P_DoQuote(QUOTE_BOOTS_ON, p); p->inv_amount[GET_BOOTS] -= 2; if (p->inv_amount[GET_BOOTS] <= 0) { @@ -5231,7 +5234,7 @@ void P_ProcessInput(int32_t snum) if (g_player[snum].sync->extbits&(1<<5) || g_player[snum].sync->avel > 0) VM_OnEvent(EVENT_TURNRIGHT,p->i,snum, -1); - if (p->posvel.x || p->posvel.y || g_player[snum].sync->fvel || g_player[snum].sync->svel) + if (p->vel.x || p->vel.y || g_player[snum].sync->fvel || g_player[snum].sync->svel) { p->crack_time = 777; @@ -5275,8 +5278,8 @@ void P_ProcessInput(int32_t snum) if (p->jetpack_on == 0 && p->inv_amount[GET_STEROIDS] > 0 && p->inv_amount[GET_STEROIDS] < 400) doubvel <<= 1; - p->posvel.x += ((g_player[snum].sync->fvel*doubvel)<<6); - p->posvel.y += ((g_player[snum].sync->svel*doubvel)<<6); + p->vel.x += ((g_player[snum].sync->fvel*doubvel)<<6); + p->vel.y += ((g_player[snum].sync->svel*doubvel)<<6); j = 0; @@ -5285,16 +5288,16 @@ void P_ProcessInput(int32_t snum) else if (p->on_ground && (TEST_SYNC_KEY(sb_snum, SK_CROUCH) || (*kb > 10 && aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON))) j = 0x2000; - p->posvel.x = mulscale16(p->posvel.x,p->runspeed-j); - p->posvel.y = mulscale16(p->posvel.y,p->runspeed-j); + p->vel.x = mulscale16(p->vel.x,p->runspeed-j); + p->vel.y = mulscale16(p->vel.y,p->runspeed-j); - if (klabs(p->posvel.x) < 2048 && klabs(p->posvel.y) < 2048) - p->posvel.x = p->posvel.y = 0; + if (klabs(p->vel.x) < 2048 && klabs(p->vel.y) < 2048) + p->vel.x = p->vel.y = 0; if (shrunk) { - p->posvel.x = mulscale16(p->posvel.x,p->runspeed-(p->runspeed>>1)+(p->runspeed>>2)); - p->posvel.y = mulscale16(p->posvel.y,p->runspeed-(p->runspeed>>1)+(p->runspeed>>2)); + p->vel.x = mulscale16(p->vel.x,p->runspeed-(p->runspeed>>1)+(p->runspeed>>2)); + p->vel.y = mulscale16(p->vel.y,p->runspeed-(p->runspeed>>1)+(p->runspeed>>2)); } } @@ -5307,12 +5310,12 @@ HORIZONLY: if (ud.clipping) { - p->pos.x += p->posvel.x>>14; - p->pos.y += p->posvel.y>>14; + p->pos.x += p->vel.x>>14; + p->pos.y += p->vel.y>>14; updatesector(p->pos.x,p->pos.y,&p->cursectnum); changespritesect(p->i,p->cursectnum); } - else if ((j = clipmove((vec3_t *)p,&p->cursectnum, p->posvel.x,p->posvel.y,164L,(4L<<8),i,CLIPMASK0))) + else if ((j = clipmove((vec3_t *)p,&p->cursectnum, p->vel.x,p->vel.y,164L,(4L<<8),i,CLIPMASK0))) P_CheckTouchDamage(p, j); if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) @@ -5369,7 +5372,7 @@ HORIZONLY: { if (!(sector[s->sectnum].lotag&0x8000) && (isanunderoperator(sector[s->sectnum].lotag) || isanearoperator(sector[s->sectnum].lotag))) - activatebysector(s->sectnum,p->i); + G_ActivateBySector(s->sectnum,p->i); if (j) { P_QuickKill(p); @@ -5377,7 +5380,7 @@ HORIZONLY: } } else if (klabs(fz-cz) < (32<<8) && isanunderoperator(sector[p->cursectnum].lotag)) - activatebysector(p->cursectnum,p->i); + G_ActivateBySector(p->cursectnum,p->i); } i = 0; @@ -5809,7 +5812,7 @@ void computergetinput(int32_t snum, input_t *syn) if (fightdist < 128) fightdist = 128; dist = ksqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); if (dist == 0) dist = 1; - daang = getangle(x2+(g_player[goalplayer[snum]].ps->posvel.x>>14)-x1,y2+(g_player[goalplayer[snum]].ps->posvel.y>>14)-y1); + daang = getangle(x2+(g_player[goalplayer[snum]].ps->vel.x>>14)-x1,y2+(g_player[goalplayer[snum]].ps->vel.y>>14)-y1); zang = 100-((z2-z1)*8)/dist; fightdist = max(fightdist,(klabs(z2-z1)>>4)); @@ -6048,13 +6051,13 @@ void computergetinput(int32_t snum, input_t *syn) int16_t dasect = p->cursectnum; Bmemcpy(&vect,p,sizeof(vec3_t)); - i = clipmove(&vect,&dasect,p->posvel.x,p->posvel.y,164L,4L<<8,4L<<8,CLIPMASK0); + i = clipmove(&vect,&dasect,p->vel.x,p->vel.y,164L,4L<<8,4L<<8,CLIPMASK0); if (!i) { Bmemcpy(&vect,p,sizeof(vec3_t)); vect.z += (24<<8); dasect = p->cursectnum; - i = clipmove(&vect,&dasect,p->posvel.x,p->posvel.y,164L,4L<<8,4L<<8,CLIPMASK0); + i = clipmove(&vect,&dasect,p->vel.x,p->vel.y,164L,4L<<8,4L<<8,CLIPMASK0); } } if (i) diff --git a/polymer-perf/eduke32/source/player.h b/polymer-perf/eduke32/source/player.h index f47b31b70..91e87a501 100644 --- a/polymer-perf/eduke32/source/player.h +++ b/polymer-perf/eduke32/source/player.h @@ -33,6 +33,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define AUTO_AIM_ANGLE 48 #define PHEIGHT (38<<8) +#define TRIPBOMB_TRIPWIRE 0x00000001 +#define TRIPBOMB_TIMER 0x00000002 + +#define PIPEBOMB_REMOTE 0x00000001 +#define PIPEBOMB_TIMER 0x00000002 + enum dukeinv_t { GET_STEROIDS, GET_SHIELD, @@ -116,12 +122,6 @@ enum playeraction_t { pfacing = 0x00010000 }; -#define TRIPBOMB_TRIPWIRE 0x00000001 -#define TRIPBOMB_TIMER 0x00000002 - -#define PIPEBOMB_REMOTE 0x00000001 -#define PIPEBOMB_TIMER 0x00000002 - #pragma pack(push,1) typedef struct { int32_t ox,oy,oz; @@ -137,7 +137,7 @@ typedef struct { } DukeStatus_t; typedef struct { - vec3_t pos, opos, posvel; + vec3_t pos, opos, vel, npos; int32_t bobposx, bobposy; int32_t truefz, truecz, player_par; int32_t randomflamex, exitx, exity; @@ -213,7 +213,7 @@ typedef struct { int32_t pcolor, pteam; uint8_t frags[MAXPLAYERS], wchoice[MAX_WEAPONS]; - char vote, gotvote, playerreadyflag, playerquitflag; + char vote, gotvote, pingcnt, playerquitflag; char user_name[32]; } playerdata_t; #pragma pack(pop) @@ -261,7 +261,7 @@ extern int32_t g_numObituaries; extern int32_t g_numSelfObituaries; extern int32_t g_weapon_offset; extern int32_t g_weapon_xoffset; -extern int32_t jump_timer; +extern int32_t g_emuJumpTics; extern int32_t lastvisinc; extern int32_t mouseyaxismode; extern int32_t ticrandomseed; diff --git a/polymer-perf/eduke32/source/premap.c b/polymer-perf/eduke32/source/premap.c index fd52df11b..59b1b28b4 100644 --- a/polymer-perf/eduke32/source/premap.c +++ b/polymer-perf/eduke32/source/premap.c @@ -489,7 +489,7 @@ void G_CacheMapData(void) if (waloff[i] == 0) loadtile((int16_t)i); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL // PRECACHE if (ud.config.useprecache) { @@ -544,7 +544,7 @@ void G_CacheMapData(void) OSD_Printf("Cache time: %dms\n", endtime-starttime); } -void xyzmirror(int32_t i,int32_t wn) +void G_SetupCamTile(int32_t i,int32_t wn) { //if (waloff[wn] == 0) loadtile(wn); setviewtotile(wn,tilesizy[wn],tilesizx[wn]); @@ -678,7 +678,7 @@ void P_ResetPlayer(int32_t snum) g_player[snum].ps->weapreccnt = 0; g_player[snum].ps->fta = 0; g_player[snum].ps->ftq = 0; - g_player[snum].ps->posvel.x = g_player[snum].ps->posvel.y = 0; + g_player[snum].ps->vel.x = g_player[snum].ps->vel.y = 0; g_player[snum].ps->rotscrnang = 0; g_player[snum].ps->runspeed = g_playerFriction; g_player[snum].ps->falling_counter = 0; @@ -782,9 +782,9 @@ void P_ResetStatus(int32_t snum) p->newowner =-1; p->jumping_counter = 0; p->hard_landing = 0; - p->posvel.x = 0; - p->posvel.y = 0; - p->posvel.z = 0; + p->vel.x = 0; + p->vel.y = 0; + p->vel.z = 0; fricxv = 0; fricyv = 0; p->somethingonplayer =-1; @@ -1560,31 +1560,26 @@ void G_ResetTimers(void) g_moveThingsCount = 0; } -void clearfifo(void) +void G_ClearFIFO(void) { - int32_t i = 0; - extern int32_t jump_timer; + int32_t i = MAXPLAYERS-1; + + g_emuJumpTics = 0; - jump_timer = 0; - avg.fvel = avg.svel = avg.avel = avg.horz = avg.bits = avg.extbits = 0; + Bmemset(&avg, 0, sizeof(input_t)); clearbufbyte(&loc,sizeof(input_t),0L); clearbufbyte(&inputfifo,sizeof(input_t)*MOVEFIFOSIZ*MAXPLAYERS,0L); - for (; i= 0; i--) { -// Bmemset(g_player[i].inputfifo,0,sizeof(g_player[i].inputfifo)); if (g_player[i].sync != NULL) - Bmemset(g_player[i].sync,0,sizeof(input_t)); - g_player[i].vote = 0; - g_player[i].gotvote = 0; + Bmemset(g_player[i].sync, 0, sizeof(input_t)); + g_player[i].vote = g_player[i].gotvote = 0; } - // clearbufbyte(playerquitflag,MAXPLAYERS,0x01); } -extern int32_t voting, vote_map, vote_episode; - -int32_t G_FindLevelForFilename(const char *fn) +int32_t G_FindLevelByFile(const char *fn) { int32_t volume, level; @@ -1637,8 +1632,10 @@ static void G_LoadMapHack(char *outbuf, const char *filename) if (filename != NULL) Bstrcpy(outbuf, filename); + p = Bstrrchr(outbuf,'.'); - if (!p) Bstrcat(outbuf,".mhk"); + if (!p) + Bstrcat(outbuf,".mhk"); else { p[1]='m'; @@ -1646,7 +1643,9 @@ static void G_LoadMapHack(char *outbuf, const char *filename) p[3]='k'; p[4]=0; } - if (!loadmaphack(outbuf)) initprintf("Loaded map hack file '%s'\n",outbuf); + + if (!loadmaphack(outbuf)) + initprintf("Loaded map hack file '%s'\n",outbuf); } int32_t G_EnterLevel(int32_t g) @@ -1671,18 +1670,21 @@ int32_t G_EnterLevel(int32_t g) if ((g&MODE_DEMO) == 0 && ud.recstat == 2) ud.recstat = 0; - FX_StopAllSounds(); - S_ClearSoundLocks(); - FX_SetReverb(0); + if (g_networkMode != NET_DEDICATED_SERVER) + { + FX_StopAllSounds(); + S_ClearSoundLocks(); + FX_SetReverb(0); + setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP); + } - setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP); if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0) { int32_t volume, level; Bcorrectfilename(boardfilename,0); - volume = level = G_FindLevelForFilename(boardfilename); + volume = level = G_FindLevelByFile(boardfilename); if (level != MAXLEVELS*MAXVOLUMES) { @@ -1811,7 +1813,6 @@ int32_t G_EnterLevel(int32_t g) } else { - i = strlen(MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename); copybufbyte(MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename,&levname[0],i); levname[i] = 255; @@ -1871,7 +1872,7 @@ int32_t G_EnterLevel(int32_t g) G_OpenDemoWrite(); if (VOLUMEONE && ud.level_number == 0 && ud.recstat != 2) - P_DoQuote(40,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_F1HELP,g_player[myconnectindex].ps); TRAVERSE_CONNECT(i) switch (DynamicTileMap[sector[sprite[g_player[i].ps->i].sectnum].floorpicnum]) @@ -1904,7 +1905,7 @@ int32_t G_EnterLevel(int32_t g) ud.last_level = ud.level_number+1; - clearfifo(); + G_ClearFIFO(); for (i=g_numInterpolations-1; i>=0; i--) bakipos[i] = *curipos[i]; diff --git a/polymer-perf/eduke32/source/premap.h b/polymer-perf/eduke32/source/premap.h index 81fbf3abf..0b45aee1d 100644 --- a/polymer-perf/eduke32/source/premap.h +++ b/polymer-perf/eduke32/source/premap.h @@ -32,7 +32,7 @@ extern int32_t g_numRealPalettes; extern int32_t voting,vote_map,vote_episode; extern palette_t CrosshairColors; int32_t G_EnterLevel(int32_t g); -int32_t G_FindLevelForFilename(const char *fn); +int32_t G_FindLevelByFile(const char *fn); void G_CacheMapData(void); void G_FadeLoad(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step); void G_FreeMapState(int32_t mapnum); @@ -45,7 +45,7 @@ void P_ResetInventory(int32_t snum); void P_ResetPlayer(int32_t snum); void P_ResetStatus(int32_t snum); void P_ResetWeapons(int32_t snum); -void clearfifo(void); -void xyzmirror(int32_t i,int32_t wn); +void G_ClearFIFO(void); +void G_SetupCamTile(int32_t i,int32_t wn); #endif diff --git a/polymer-perf/eduke32/source/quotes.h b/polymer-perf/eduke32/source/quotes.h new file mode 100644 index 000000000..d5a1ad436 --- /dev/null +++ b/polymer-perf/eduke32/source/quotes.h @@ -0,0 +1,96 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2011 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +//------------------------------------------------------------------------- + +#ifndef __quotes_h__ +#define __quotes_h__ + +#define MAXQUOTES 16384 +#define MAXQUOTELEN 128 +#define OBITQUOTEINDEX MAXQUOTES-128 +#define SUICIDEQUOTEINDEX MAXQUOTES-32 + +#define QUOTE_SHOW_MAP_OFF 1 +#define QUOTE_ACTIVATED 2 +#define QUOTE_MEDKIT 3 +#define QUOTE_LOCKED 4 +#define QUOTE_CHEAT_EVERYTHING 5 +#define QUOTE_BOOTS 6 +#define QUOTE_WASTED 7 +#define QUOTE_UNLOCKED 8 +#define QUOTE_FOUND_SECRET 9 +#define QUOTE_SQUISHED 10 +#define QUOTE_USED_STEROIDS 12 +#define QUOTE_DEACTIVATED 15 +#define QUOTE_CHEAT_GODMODE_ON 17 +#define QUOTE_CHEAT_GODMODE_OFF 18 +#define QUOTE_CROSSHAIR_OFF 21 +#define QUOTE_CHEATS_DISABLED 22 +#define QUOTE_MESSAGES_ON 23 +#define QUOTE_MESSAGES_OFF 24 +#define QUOTE_MUSIC 26 +#define QUOTE_CHEAT_STEROIDS 37 +#define QUOTE_F1HELP 40 +#define QUOTE_MOUSE_AIMING_OFF 44 +#define QUOTE_HOLODUKE_ON 47 +#define QUOTE_HOLODUKE_OFF 48 +#define QUOTE_HOLODUKE_NOT_FOUND 49 +#define QUOTE_JETPACK_NOT_FOUND 50 +#define QUOTE_JETPACK_ON 52 +#define QUOTE_JETPACK_OFF 53 +#define QUOTE_NEED_BLUE_KEY 70 +#define QUOTE_NEED_RED_KEY 71 +#define QUOTE_NEED_YELLOW_KEY 72 +#define QUOTE_WEAPON_LOWERED 73 +#define QUOTE_WEAPON_RAISED 74 +#define QUOTE_BOOTS_ON 75 +#define QUOTE_SCUBA_ON 76 +#define QUOTE_CHEAT_ALLEN 79 +#define QUOTE_MIGHTY_FOOT 80 +#define QUOTE_WEAPON_MODE_OFF 82 +#define QUOTE_MAP_FOLLOW_OFF 83 +#define QUOTE_RUN_MODE_OFF 85 +#define QUOTE_JETPACK 88 +#define QUOTE_SCUBA 89 +#define QUOTE_STEROIDS 90 +#define QUOTE_HOLODUKE 91 +#define QUOTE_CHEAT_TODD 99 +#define QUOTE_CHEAT_UNLOCK 100 +#define QUOTE_NVG 101 +#define QUOTE_WEREGONNAFRYYOURASS 102 +#define QUOTE_SCREEN_SAVED 103 +#define QUOTE_CHEAT_BETA 105 +#define QUOTE_NVG_OFF 107 +#define QUOTE_VIEW_MODE_OFF 109 +#define QUOTE_SHOW_MAP_ON 111 +#define QUOTE_CHEAT_NOCLIP 113 +#define QUOTE_SAVE_BAD_VERSION 114 +#define QUOTE_RESERVED 115 +#define QUOTE_RESERVED2 116 +#define QUOTE_RESERVED3 117 +#define QUOTE_SAVE_DEAD 118 +#define QUOTE_CHEAT_ALL_WEAPONS 119 +#define QUOTE_CHEAT_ALL_INV 120 +#define QUOTE_CHEAT_ALL_KEYS 121 +#define QUOTE_RESERVED4 122 +#define QUOTE_SAVE_BAD_PLAYERS 124 + +#endif diff --git a/polymer-perf/eduke32/source/rev.h b/polymer-perf/eduke32/source/rev.h new file mode 100644 index 000000000..24e51dcc3 --- /dev/null +++ b/polymer-perf/eduke32/source/rev.h @@ -0,0 +1 @@ +const char *s_buildRev = "rXXXX"; diff --git a/polymer-perf/eduke32/source/savegame.c b/polymer-perf/eduke32/source/savegame.c index d55248c87..fb4f57faa 100644 --- a/polymer-perf/eduke32/source/savegame.c +++ b/polymer-perf/eduke32/source/savegame.c @@ -99,7 +99,7 @@ int32_t G_LoadSaveHeader(char spot,struct savehead *saveh) if (kdfread(&bv,sizeof(bv),1,fil) != 1) goto corrupt; /* if (bv != BYTEVERSION) { - P_DoQuote(114,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_SAVE_BAD_VERSION,g_player[myconnectindex].ps); kclose(fil); return 1; }*/ @@ -154,7 +154,7 @@ int32_t G_LoadPlayer(int32_t spot) if (kdfread(&bv,sizeof(bv),1,fil) != 1) return -1; if (bv != BYTEVERSION) { - P_DoQuote(114,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_SAVE_BAD_VERSION,g_player[myconnectindex].ps); kclose(fil); ototalclock = totalclock; ready2send = 1; @@ -167,7 +167,7 @@ int32_t G_LoadPlayer(int32_t spot) kclose(fil); ototalclock = totalclock; ready2send = 1; - P_DoQuote(124,g_player[myconnectindex].ps); + P_DoQuote(QUOTE_SAVE_BAD_PLAYERS,g_player[myconnectindex].ps); return 1; } else ud.multimode = nump; @@ -255,7 +255,7 @@ int32_t G_LoadPlayer(int32_t spot) if (kdfread(&i,sizeof(int32_t),1,fil) != 1) goto corrupt; #endif // POLYMER -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL for (i=0; igm = MODE_GAME; ud.recstat = 0; @@ -590,7 +594,7 @@ int32_t G_LoadPlayer(int32_t spot) ready2send = 1; - clearfifo(); + G_ClearFIFO(); Net_WaitForServer(); G_ResetTimers(); @@ -676,7 +680,7 @@ int32_t G_SavePlayer(int32_t spot) dfwrite(&numsectors,sizeof(numsectors),1,fil); dfwrite(§or[0],sizeof(sectortype),MAXSECTORS,fil); dfwrite(&sprite[0],sizeof(spritetype),MAXSPRITES,fil); -#if defined(POLYMOST) && defined(USE_OPENGL) +#ifdef USE_OPENGL for (i=0; ii].owner >= 0) { g_player[p].ps->pos.z += v; - g_player[p].ps->posvel.z = 0; + g_player[p].ps->vel.z = 0; if (p == myconnectindex) { my.z += v; @@ -381,7 +381,7 @@ void G_AnimateCamSprite(void) if (waloff[TILE_VIEWSCR] == 0) allocatepermanenttile(TILE_VIEWSCR,tilesizx[PN],tilesizy[PN]); else walock[TILE_VIEWSCR] = 255; - xyzmirror(OW,/*PN*/TILE_VIEWSCR); + G_SetupCamTile(OW,/*PN*/TILE_VIEWSCR); } } else T1++; @@ -1046,8 +1046,8 @@ void G_OperateActivators(int32_t low,int32_t snum) if (snum >= 0 && snum < ud.multimode) { if (sector[SECT].lotag&16384) - P_DoQuote(4,g_player[snum].ps); - else P_DoQuote(8,g_player[snum].ps); + P_DoQuote(QUOTE_LOCKED,g_player[snum].ps); + else P_DoQuote(QUOTE_UNLOCKED,g_player[snum].ps); } } else @@ -1222,21 +1222,21 @@ int32_t P_ActivateSwitch(int32_t snum,int32_t w,int32_t switchtype) { if ((g_player[snum].ps->got_access&1)) g_player[snum].ps->access_incs = 1; - else P_DoQuote(70,g_player[snum].ps); + else P_DoQuote(QUOTE_NEED_BLUE_KEY,g_player[snum].ps); } else if (switchpal == 21) { if (g_player[snum].ps->got_access&2) g_player[snum].ps->access_incs = 1; - else P_DoQuote(71,g_player[snum].ps); + else P_DoQuote(QUOTE_NEED_RED_KEY,g_player[snum].ps); } else if (switchpal == 23) { if (g_player[snum].ps->got_access&4) g_player[snum].ps->access_incs = 1; - else P_DoQuote(72,g_player[snum].ps); + else P_DoQuote(QUOTE_NEED_YELLOW_KEY,g_player[snum].ps); } if (g_player[snum].ps->access_incs == 1) @@ -1565,11 +1565,11 @@ int32_t P_ActivateSwitch(int32_t snum,int32_t w,int32_t switchtype) case 25: actor[x].t_data[4] = !actor[x].t_data[4]; if (actor[x].t_data[4]) - P_DoQuote(15,g_player[snum].ps); - else P_DoQuote(2,g_player[snum].ps); + P_DoQuote(QUOTE_DEACTIVATED,g_player[snum].ps); + else P_DoQuote(QUOTE_ACTIVATED,g_player[snum].ps); break; case 21: - P_DoQuote(2,g_player[screenpeek].ps); + P_DoQuote(QUOTE_ACTIVATED,g_player[screenpeek].ps); break; } } @@ -1603,7 +1603,7 @@ int32_t P_ActivateSwitch(int32_t snum,int32_t w,int32_t switchtype) } -void activatebysector(int32_t sect,int32_t j) +void G_ActivateBySector(int32_t sect,int32_t j) { int32_t i = headspritesect[sect]; int32_t didit = 0; @@ -2383,7 +2383,7 @@ void A_DamageObject(int32_t i,int32_t sn) sprite[i].xvel = -(sprite[sn].extra<<2); j = SECT; pushmove((vec3_t *)&sprite[i],&j,128L,(4L<<8),(4L<<8),CLIPMASK0); - if (j != SECT && j >= 0 && j < MAXSECTORS) + if (j != SECT && (unsigned)j < MAXSECTORS) changespritesect(i,j); } } @@ -2521,7 +2521,7 @@ void G_HandleSharedKeys(int32_t snum) { p->quick_kick = 14; if (p->fta == 0 || p->ftq == 80) - P_DoQuote(80,p); + P_DoQuote(QUOTE_MIGHTY_FOOT,p); } } @@ -2597,7 +2597,7 @@ void G_HandleSharedKeys(int32_t snum) P_UpdateScreenPal(p); p->inven_icon = 5; A_PlaySound(NITEVISION_ONOFF,p->i); - P_DoQuote(106+(!p->heat_on),p); + P_DoQuote(QUOTE_NVG_OFF-p->heat_on,p); } } @@ -2611,7 +2611,7 @@ void G_HandleSharedKeys(int32_t snum) { p->inv_amount[GET_STEROIDS]--; A_PlaySound(DUKE_TAKEPILLS,p->i); - P_DoQuote(12,p); + P_DoQuote(QUOTE_USED_STEROIDS,p); } if (p->inv_amount[GET_STEROIDS] > 0) p->inven_icon = 2; @@ -2710,7 +2710,8 @@ CHECKINV1: if (dainv || p->inv_amount[GET_FIRSTAID]) { - static const int32_t i[8] = { 3, 90, 91, 88, 101, 89, 6, 0 }; + static const int32_t i[8] = { QUOTE_MEDKIT, QUOTE_STEROIDS, QUOTE_HOLODUKE, + QUOTE_JETPACK, QUOTE_NVG, QUOTE_SCUBA, QUOTE_BOOTS, 0 }; P_DoQuote(i[dainv-1], p); } } @@ -2919,11 +2920,11 @@ CHECKINV1: T4 = T5 = 0; SP = snum; sprite[i].extra = 0; - P_DoQuote(47,p); + P_DoQuote(QUOTE_HOLODUKE_ON,p); A_PlaySound(TELEPORTER,p->holoduke_on); } } - else P_DoQuote(49,p); + else P_DoQuote(QUOTE_HOLODUKE_NOT_FOUND,p); } } else @@ -2934,7 +2935,7 @@ CHECKINV1: { A_PlaySound(TELEPORTER,p->holoduke_on); p->holoduke_on = -1; - P_DoQuote(48,p); + P_DoQuote(QUOTE_HOLODUKE_OFF,p); } } } @@ -2966,7 +2967,7 @@ CHECKINV1: } } - if (TEST_SYNC_KEY(sb_snum, SK_JETPACK) && p->newowner == -1) + if (p->newowner == -1 && TEST_SYNC_KEY(sb_snum, SK_JETPACK)) { aGameVars[g_iReturnVarID].val.lValue = 0; VM_OnEvent(EVENT_USEJETPACK,g_player[snum].ps->i,snum, -1); @@ -2986,19 +2987,19 @@ CHECKINV1: A_PlaySound(DUKE_JETPACK_ON,p->i); - P_DoQuote(52,p); + P_DoQuote(QUOTE_JETPACK_ON,p); } else { p->hard_landing = 0; - p->posvel.z = 0; + p->vel.z = 0; A_PlaySound(DUKE_JETPACK_OFF,p->i); S_StopEnvSound(DUKE_JETPACK_IDLE,p->i); S_StopEnvSound(DUKE_JETPACK_ON,p->i); - P_DoQuote(53,p); + P_DoQuote(QUOTE_JETPACK_OFF,p); } } - else P_DoQuote(50,p); + else P_DoQuote(QUOTE_JETPACK_NOT_FOUND,p); } } @@ -3031,13 +3032,14 @@ int32_t A_CheckHitSprite(int32_t i, int16_t *hitsp) SZ += zoff; *hitsp = hitinfo.hitsprite; + if (hitinfo.hitwall >= 0 && (wall[hitinfo.hitwall].cstat&16) && A_CheckEnemySprite(&sprite[i])) return((1<<30)); return (FindDistance2D(hitinfo.pos.x-SX,hitinfo.pos.y-SY)); } -static int32_t hitawall(DukePlayer_t *p,int16_t *hitw) +static int32_t P_FindWall(DukePlayer_t *p,int16_t *hitw) { hitdata_t hitinfo; @@ -3064,7 +3066,7 @@ void P_CheckSectors(int32_t snum) case 32767: sector[p->cursectnum].lotag = 0; - P_DoQuote(9,p); + P_DoQuote(QUOTE_FOUND_SECRET,p); p->secret_rooms++; return; case -1: @@ -3144,7 +3146,7 @@ void P_CheckSectors(int32_t snum) p->toggle_key_flag = 1; hitscanwall = -1; - i = hitawall(p,&hitscanwall); + i = P_FindWall(p,&hitscanwall); if (i < 1280 && hitscanwall >= 0 && wall[hitscanwall].overpicnum == MIRROR) if (wall[hitscanwall].lotag > 0 && !A_CheckSoundPlaying(p->i,wall[hitscanwall].lotag) && snum == screenpeek) @@ -3247,7 +3249,7 @@ void P_CheckSectors(int32_t snum) return; case NUKEBUTTON__STATIC: - hitawall(p,&j); + P_FindWall(p,&j); if (j >= 0 && wall[j].overpicnum == 0) if (actor[neartagsprite].t_data[0] == 0) { diff --git a/polymer-perf/eduke32/source/sector.h b/polymer-perf/eduke32/source/sector.h index 8fac935b5..9770db1d7 100644 --- a/polymer-perf/eduke32/source/sector.h +++ b/polymer-perf/eduke32/source/sector.h @@ -25,9 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "gamevars.h" -#define MAXCYCLERS 1024 -#define MAXANIMATES 256 -#define MAXANIMWALLS 512 +#define MAXCYCLERS 1024 +#define MAXANIMATES 256 +#define MAXANIMWALLS 512 typedef struct { int16_t wallnum, tag; @@ -85,7 +85,7 @@ typedef struct { extern map_t MapInfo[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" music -void activatebysector(int32_t sect,int32_t j); +void G_ActivateBySector(int32_t sect,int32_t j); int32_t A_CallSound(int32_t sn,int32_t whatsprite); int32_t A_CheckHitSprite(int32_t i,int16_t *hitsp); void A_DamageObject(int32_t i,int32_t sn); diff --git a/polymer-perf/eduke32/source/sounds.c b/polymer-perf/eduke32/source/sounds.c index ae95c173b..6e6da5209 100644 --- a/polymer-perf/eduke32/source/sounds.c +++ b/polymer-perf/eduke32/source/sounds.c @@ -386,7 +386,7 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos) ((g_sounds[num].m&8) && ud.lockout) || ud.config.SoundToggle == 0 || g_sounds[num].num >= MAXSOUNDINSTANCES || - i < 0 || i >= MAXSPRITES || + (unsigned)i >= MAXSPRITES || FX_VoiceAvailable(g_sounds[num].pr) == 0 || (g_player[myconnectindex].ps->timebeforeexit > 0 && g_player[myconnectindex].ps->timebeforeexit <= GAMETICSPERSEC*3) || g_player[myconnectindex].ps->gm&MODE_MENU) return -1; @@ -458,6 +458,8 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos) pitch -= 1024; break; default: + if (sndist > 32767 && PN != MUSICANDSFX && (g_sounds[num].m & 3) == 0) + return -1; if (g_player[screenpeek].ps->cursectnum > -1 && sector[g_player[screenpeek].ps->cursectnum].lotag == 2 && (g_sounds[num].m&4) == 0) pitch = -768; break; @@ -611,7 +613,7 @@ int32_t S_PlaySound(int32_t num) int32_t A_PlaySound(uint32_t num, int32_t i) { - if ((int32_t)num > g_maxSoundPos) return -1; + if ((unsigned)num > (unsigned)g_maxSoundPos) return -1; return i < 0 ? S_PlaySound(num) : S_PlaySound3D(num, i, (vec3_t *)&sprite[i]); } @@ -619,7 +621,7 @@ void S_StopEnvSound(int32_t num, int32_t i) { int32_t j, iter = 0; - if (num < 0 || num > g_maxSoundPos || g_sounds[num].num <= 0) + if ((unsigned)num > (unsigned)g_maxSoundPos || g_sounds[num].num <= 0) return; do @@ -690,7 +692,7 @@ void S_Update(void) { i = g_sounds[j].SoundOwner[k].i; - if (i < 0 || i >= MAXSPRITES || g_sounds[j].num == 0 || g_sounds[j].SoundOwner[k].voice <= FX_Ok) + if ((unsigned)i >= MAXSPRITES || g_sounds[j].num == 0 || g_sounds[j].SoundOwner[k].voice <= FX_Ok) continue; if (!FX_SoundActive(g_sounds[j].SoundOwner[k].voice)) @@ -734,9 +736,7 @@ void S_Update(void) break; } - if (g_sounds[j].m&16) sndist = 0; - - if (sndist < ((255-LOUDESTVOLUME)<<6)) + if (g_sounds[j].m&16 || sndist < ((255-LOUDESTVOLUME)<<6)) sndist = ((255-LOUDESTVOLUME)<<6); FX_Pan3D(g_sounds[j].SoundOwner[k].voice, sndang>>4, sndist>>6); diff --git a/polymer-perf/eduke32/source/startwin.game.c b/polymer-perf/eduke32/source/startwin.game.c index 16c83627e..028b1feb3 100644 --- a/polymer-perf/eduke32/source/startwin.game.c +++ b/polymer-perf/eduke32/source/startwin.game.c @@ -95,7 +95,7 @@ static inline int32_t getfilenames(char *path) #define POPULATE_GAME 4 #define POPULATE_GAMEDIRS 8 -#if defined(POLYMOST) +#ifdef USE_OPENGL extern char TEXCACHEFILE[]; #endif diff --git a/polymer-perf/synthesis.sh b/polymer-perf/synthesis.sh index db9bc934e..cb8b09269 100755 --- a/polymer-perf/synthesis.sh +++ b/polymer-perf/synthesis.sh @@ -73,6 +73,8 @@ then echo rm mapster32.debug.exe rm mapster32.debug.exe + # throw the svn revision into a header. this is ugly. + echo "const char *s_buildRev = \"r$head\";" > source/rev.h # clean the tree and build debug first echo "${make[@]}" RELEASE=0 $clean all "${make[@]}" RELEASE=0 $clean all