Merge 1775:1799 to polymer-broken.

git-svn-id: https://svn.eduke32.com/eduke32@1800 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
plagman 2011-02-22 02:34:18 +00:00
parent 71d5dc5e59
commit 563bac46ab
45 changed files with 1882 additions and 1374 deletions

View file

@ -113,15 +113,17 @@ endif
ifeq ($(PLATFORM),DARWIN)
ifeq (1,$(SDL_FRAMEWORK))
OURCFLAGS += -fno-pic -IApple/include -I/Library/Frameworks/SDL.framework/Headers \
-I-I/Library/Frameworks/SDL_mixer.framework/Headers
APPLE_INCLUDE_DIR=$(abspath Apple/include)
OURCFLAGS += -fno-pic -I$(APPLE_INCLUDE_DIR) -I/Library/Frameworks/SDL.framework/Headers \
-I/Library/Frameworks/SDL_mixer.framework/Headers
LIBS += -read_only_relocs suppress -LApple/lib -lvorbisfile -lvorbis -logg -lm \
-Wl,-framework,SDL -Wl,-framework,SDL_mixer Apple/lib/libSDLmain.a \
-Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,OpenGL \
-Wl,-framework,CoreMidi -Wl,-framework,AudioUnit \
-Wl,-framework,AudioToolbox -Wl,-framework,IOKit -Wl,-framework,AGL \
-Wl,-framework,QuickTime -lm
# I like to have the SDLMain.m from the OSX SDL package to be in this dir:
LIBS += $(realpath SDLMain.m)
else
OURCFLAGS += -fno-pic -I$(SDLROOT)/include -I$(SDLROOT)/include/SDL
LIBS += -read_only_relocs suppress -lvorbisfile -lvorbis -logg -lm -lSDL_mixer \
@ -196,14 +198,14 @@ notice:
eduke32$(EXESUFFIX): $(GAMEOBJS) $(EOBJ)/$(ENGINELIB) $(JAUDIOLIBDIR)/$(JAUDIOLIB) $(ENETDIR)/$(ENETLIB)
$(LINK_STATUS)
if $(CC) -o $@ $^ $(LIBS) $(STDCPPLIB) $(MISCLINKOPTS); then $(LINK_OK); else $(LINK_FAILED); fi
if $(CC) $(CFLAGS) $(OURCFLAGS) -o $@ $^ $(LIBS) $(STDCPPLIB) $(MISCLINKOPTS); then $(LINK_OK); else $(LINK_FAILED); fi
ifeq (1,$(RELEASE))
ifeq (0,$(DEBUGANYWAY))
$(STRIP) eduke32$(EXESUFFIX)
endif
endif
mapster32$(EXESUFFIX): $(EDITOROBJS) $(EOBJ)/$(EDITORLIB) $(EOBJ)/$(ENGINELIB) $(JAUDIOLIBDIR)/$(JAUDIOLIB) $(ENETDIR)/$(ENETLIB)
mapster32$(EXESUFFIX): $(EDITOROBJS) $(EOBJ)/$(EDITORLIB) $(EOBJ)/$(ENGINELIB) $(JAUDIOLIBDIR)/$(JAUDIOLIB)
$(LINK_STATUS)
if $(CC) $(CFLAGS) $(OURCFLAGS) -o $@ $^ $(LIBS) $(STDCPPLIB) $(MISCLINKOPTS); then $(LINK_OK); else $(LINK_FAILED); fi
ifeq (1,$(RELEASE))
@ -282,7 +284,7 @@ $(OBJ)/%.$o: $(RSRC)/%.c
$(OBJ)/game_banner.$o: $(RSRC)/game_banner.c
$(COMPILE_STATUS)
if $(CC) $(CFLAGS) $(OURCFLAGS) -Wno-pointer-sign -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
$(OBJ)/editor_banner.$o: $(RSRC)/editor_banner.c
$(COMPILE_STATUS)
if $(CC) $(CFLAGS) $(OURCFLAGS) -Wno-pointer-sign -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi

View file

@ -3,14 +3,13 @@
## source/jaudiolib/Makefile
# Use colored output
PRETTY_OUTPUT = 1
PRETTY_OUTPUT ?= 1
# DirectX SDK location - if nonempty, overrides the DXROOTs of the individual
# Makefiles. Should be set to an absolute path since this Makefile is included
# at different directory levels
DXROOT_OVERRIDE:=
# Engine options
# SUPERBUILD - enables voxels
# POLYMOST - enables Polymost renderer
@ -88,9 +87,12 @@ ifneq (0,$(DEBUGANYWAY))
debug+=-ggdb
endif
W_NO_UNUSED_RESULT := $(shell echo '' | $(CC) -E -Wno-unused-result - 2>/dev/null && echo -Wno-unused-result)
W_NO_UNUSED_RESULT := $(findstring -Wno-unused-result,$(W_NO_UNUSED_RESULT))
BASECFLAGS=$(debug) -W -Wall -Wimplicit -Werror-implicit-function-declaration \
-funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -D_FORTIFY_SOURCE=2 \
$(F_JUMP_TABLES) -Wno-unused-result
$(F_JUMP_TABLES) $(W_NO_UNUSED_RESULT)
BASECXXFLAGS= -fno-exceptions -fno-rtti
BASEASFLAGS=-s #-g

View file

@ -160,7 +160,7 @@ OURCFLAGS+= $(BUILDCFLAGS)
# TARGETS
UTILS=kextract$(EXESUFFIX) kgroup$(EXESUFFIX) transpal$(EXESUFFIX) wad2art$(EXESUFFIX) wad2map$(EXESUFFIX)
UTILS=kextract$(EXESUFFIX) kgroup$(EXESUFFIX) transpal$(EXESUFFIX) wad2art$(EXESUFFIX) wad2map$(EXESUFFIX) md2tool$(EXESUFFIX)
# all: $(OBJ)/$(ENGINELIB) $(OBJ)/$(EDITORLIB)
utils: $(UTILS)
@ -192,6 +192,8 @@ wad2art$(EXESUFFIX): $(OBJ)/wad2art.$o $(OBJ)/pragmas.$o $(OBJ)/compat.$o $(OBJ)
$(CC) -o $@ $^ $(UTILLIBS)
wad2map$(EXESUFFIX): $(OBJ)/wad2map.$o $(OBJ)/pragmas.$o $(OBJ)/compat.$o $(OBJ)/nedmalloc.$o
$(CC) -o $@ $^ $(UTILLIBS)
md2tool$(EXESUFFIX): $(OBJ)/md2tool.$o $(OBJ)/compat.$o $(OBJ)/nedmalloc.$o
$(CC) -o $@ $^ $(UTILLIBS)
generateicon$(EXESUFFIX): $(OBJ)/generateicon.$o $(OBJ)/kplib.$o
$(CC) -o $@ $^ $(UTILLIBS)
cacheinfo$(EXESUFFIX): $(OBJ)/cacheinfo.$o $(OBJ)/compat.$o $(OBJ)/nedmalloc.$o

View file

@ -35,6 +35,7 @@ extern "C" {
#define MAXPLAYERS 16
#define MAXXDIM 3072
#define MAXYDIM 2304
#define MAXBASEPALS 8
#define MAXPALOOKUPS 256
#define MAXPSKYTILES 256
#define MAXSPRITESONSCREEN 4096
@ -59,6 +60,9 @@ extern "C" {
#define CLIPMASK0 (((1L)<<16)+1L)
#define CLIPMASK1 (((256L)<<16)+64L)
// max x/y val (= max editorgridextent in Mapster32)
#define BXY_MAX 524288
//Make all variables in BUILD.H defined in the ENGINE,
//and externed in GAME
#ifdef ENGINE
@ -136,7 +140,9 @@ typedef struct
// bit 7: 1 = Real centered centering, 0 = foot center "C"
// bit 8: 1 = Blocking sprite (use with hitscan / cliptype 1) "H"
// bit 9: 1 = Transluscence reversing, 0 = normal "T"
// bits 10-12: reserved
// bit 10: reserved (in use by a renderer hack)
// bit 11: 1 = determine shade based only on its own shade member (see CON's spritenoshade command)
// bit 12: reserved
// bit 13: 1 = does not cast shadow
// bit 14: 1 = invisible but casts shadow
// bit 15: 1 = Invisible sprite, 0 = not invisible
@ -297,7 +303,7 @@ extern int32_t rendmode;
EXTERN int32_t h_xsize[MAXTILES], h_ysize[MAXTILES];
EXTERN int8_t h_xoffs[MAXTILES], h_yoffs[MAXTILES];
extern char *engineerrstr;
extern const char *engineerrstr;
extern char noclip;
EXTERN int32_t editorzrange[2];
@ -447,7 +453,8 @@ int32_t allocatepermanenttile(int16_t tilenume, int32_t xsiz, int32_t ysiz);
void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, int32_t tilenume2, int32_t sx2, int32_t sy2);
void makepalookup(int32_t palnum, char *remapbuf, int8_t r, int8_t g, int8_t b, char dastat);
void setvgapalette(void);
void setbrightness(char dabrightness, uint8_t *dapal, char noapply);
void setbasepaltable(uint8_t **basepaltable, uint8_t basepalcount);
void setbrightness(char dabrightness, uint8_t dapalid, char noapply);
void setpalettefade(char r, char g, char b, char offset);
void squarerotatetile(int16_t tilenume);
@ -526,6 +533,7 @@ void getzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, i
void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z);
void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z);
int32_t sectorofwall(int16_t theline);
int32_t sectorofwall_noquick(int16_t theline);
int32_t loopnumofsector(int16_t sectnum, int16_t wallnum);
// int32_t insertsprite(int16_t sectnum, int16_t statnum);

View file

@ -549,7 +549,7 @@ int32_t Bcorrectfilename(char *filename, int32_t removefn);
int32_t Bcanonicalisefilename(char *filename, int32_t removefn);
char *Bgetsystemdrives(void);
int32_t Bfilelength(int32_t fd);
char *Bstrtoken(char *s, char *delim, char **ptrptr, int32_t chop);
char *Bstrtoken(char *s, const char *delim, char **ptrptr, int32_t chop);
int32_t Bwildmatch (const char *i, const char *j);
#if !defined(_WIN32)
@ -566,5 +566,8 @@ char *Bstrupr(char *);
#define EDUKE32_TMRTIC t[ti++]=getticks()
#define EDUKE32_TMRPRN do { int ii=0; fprintf(stderr,"%s: ",tmrstr); for (ii=1; ii<ti; ii++) fprintf(stderr,"%d ", t[ii]-t[ii-1]); fprintf(stderr,"\n"); } while (0)
static inline int32_t ARBNDCHK(int32_t i) { return i<0 ? (*(int32_t *)123=234) : i; }
#define DOUBLEWALL(w) wall[ARBNDCHK(w)]
#endif // __compat_h__

View file

@ -114,9 +114,9 @@ extern const char *SaveBoard(const char *fn, uint32_t flags);
#define CORRUPT_SPRITE (1<<19)
#define CORRUPT_MASK (CORRUPT_SECTOR|CORRUPT_WALL|CORRUPT_SPRITE)
#define MAXCORRUPTTHINGS 64
extern int32_t numcorruptthings, corruptthings[MAXCORRUPTTHINGS];
extern int32_t corruptlevel, numcorruptthings, corruptthings[MAXCORRUPTTHINGS];
extern int32_t autocorruptcheck;
extern int32_t CheckMapCorruption(int32_t printfromlev);
extern int32_t CheckMapCorruption(int32_t printfromlev, uint64_t tryfixing);
extern void showsectordata(int16_t sectnum, int16_t small);
extern void showwalldata(int16_t wallnum, int16_t small);
@ -215,4 +215,11 @@ extern int32_t scripthistend;
// showdebug is now used as a general informational on-screen display
#define M32_SHOWDEBUG
// this should be only used if there's no dependency on endwall after the loop.
// of course, users of this macro should know that it modifies startwall and endwall.
#define WALLS_OF_SECTOR(Sect, Itervar) \
startwall=sector[(Sect)].wallptr, endwall=startwall+sector[(Sect)].wallnum, Itervar=startwall; \
Itervar < endwall; \
Itervar++
#endif

View file

@ -42,8 +42,8 @@ enum cvartype_t
typedef struct
{
char *name;
char *helpstr;
const char *name;
const char *helpstr;
void *var;
int32_t type; // see cvartype_t
int32_t min;

View file

@ -157,7 +157,9 @@ typedef struct s_prrograminfo {
} _prprograminfo;
#define PR_INFO_LOG_BUFFER_SIZE 8192
#define PR_HIGHPALOOKUP_BIT_DEPTH 7
// Think about changing highPal[Scale|Bias] in the program bit if you change this
#define PR_HIGHPALOOKUP_BIT_DEPTH 6
#define PR_HIGHPALOOKUP_DIM (1 << PR_HIGHPALOOKUP_BIT_DEPTH)
#define PR_HIGHPALOOKUP_DATA_SIZE (4 * PR_HIGHPALOOKUP_DIM * \
PR_HIGHPALOOKUP_DIM * \
@ -244,6 +246,7 @@ typedef struct s_prwall {
int8_t shade;
char pal, xrepeat, yrepeat, xpanning, ypanning;
char nwallxpanning, nwallypanning;
int8_t nwallshade;
char underover;
uint32_t invalidid;
@ -294,7 +297,7 @@ int16_t polymer_addlight(_prlight* light);
void polymer_deletelight(int16_t lighti);
void polymer_invalidatelights(void);
void polymer_texinvalidate(void);
void polymer_definehighpalookup(char palnum, char *fn);
void polymer_definehighpalookup(char basepalnum, char palnum, char *fn);
# ifdef POLYMER_C

View file

@ -26,7 +26,7 @@ extern double gcosang, gsinang, gcosang2, gsinang2;
extern double gchang, gshang, gctang, gstang, gvisibility;
struct glfiltermodes {
char *name;
const char *name;
int32_t min,mag;
};
#define numglfiltermodes 6

View file

@ -147,7 +147,7 @@ static int32_t osdfunc_setrendermode(const osdfuncparm_t *parm)
int32_t m;
char *p;
char *modestrs[] =
const char *modestrs[] =
{
"classic software", "",
"", "polygonal OpenGL", "great justice (Polymer)"
@ -298,7 +298,7 @@ static int32_t osdcmd_cvar_set_baselayer(const osdfuncparm_t *parm)
if (!Bstrcasecmp(parm->name, "vid_gamma") || !Bstrcasecmp(parm->name, "vid_brightness") || !Bstrcasecmp(parm->name, "vid_contrast"))
{
setbrightness(GAMMA_CALC,palette,0);
setbrightness(GAMMA_CALC,0,0);
return r;
}

View file

@ -346,9 +346,14 @@ static void M32_drawdebug(void)
int x=4, y=8;
begindrawing();
// Bsprintf(tstr, "searchstat=%d, searchsector=%d, searchwall=%d",
// searchstat, searchsector, searchwall);
// printext256(x,y,whitecol,0,tstr,xdimgame>640?0:1);
#if 0
{
static char tstr[128];
Bsprintf(tstr, "searchstat=%d, searchsector=%d, searchwall=%d (%d)",
searchstat, searchsector, searchwall, searchbottomwall);
printext256(x,y,whitecol,0,tstr,xdimgame>640?0:1);
}
#endif
for (i=0; i<m32_numdebuglines; i++)
{
y+=8;
@ -490,7 +495,7 @@ int32_t app_main(int32_t argc, const char **argv)
vid_gamma = vid_contrast = 1.0;
vid_brightness = 0.0;
setbrightness(0,palette,0);
setbrightness(0,0,0);
if (setgamemode(fullscreen, xdim2d, ydim2d, 8) < 0)
{
ExtUnInit();
@ -511,7 +516,7 @@ int32_t app_main(int32_t argc, const char **argv)
vid_gamma_3d = vid_contrast_3d = vid_brightness_3d = -1;
setbrightness(GAMMA_CALC,palette,0);
setbrightness(GAMMA_CALC,0,0);
}
else
{
@ -526,7 +531,7 @@ int32_t app_main(int32_t argc, const char **argv)
// executed once per init, but after setgamemode so that OSD has the right width
OSD_Exec("m32_autoexec.cfg");
setbrightness(GAMMA_CALC,palette,0);
setbrightness(GAMMA_CALC,0,0);
}
CANCEL:
@ -580,9 +585,8 @@ CANCEL:
if (keystatus[1])
{
keystatus[1] = 0;
begindrawing(); //{{{
printext256(0,0,whitecol,0,"Are you sure you want to quit?",0);
enddrawing(); //}}}
showframe(1);
synctics = totalclock-lockclock;
@ -618,11 +622,10 @@ CANCEL:
if (asksave)
{
i = CheckMapCorruption(4);
i = CheckMapCorruption(4, 0);
begindrawing(); //{{{
printext256(0,8,whitecol,0,i<4?"Save changes?":"Map is heavily corrupt. Save changes?",0);
showframe(1); //}}}
showframe(1);
while ((keystatus[1]|keystatus[0x1c]|keystatus[0x39]|keystatus[0x31]|keystatus[0x2e]) == 0)
{
@ -891,9 +894,6 @@ void editinput(void)
keystatus[0x43] = 0;
}
begindrawing(); //{{{
enddrawing(); //}}}
if (angvel != 0) //ang += angvel * constant
{
//ENGINE calculates angvel for you
@ -1214,7 +1214,7 @@ void editinput(void)
vid_gamma = vid_contrast = 1.0;
vid_brightness = 0.0;
setbrightness(0,palette,0);
setbrightness(0,0,0);
keystatus[buildkeys[BK_MODE2D_3D]] = 0;
overheadeditor();
@ -1226,7 +1226,7 @@ void editinput(void)
vid_gamma_3d = vid_contrast_3d = vid_brightness_3d = -1;
setbrightness(GAMMA_CALC,palette,0);
setbrightness(GAMMA_CALC,0,0);
}
}
@ -1264,6 +1264,27 @@ static inline void drawline16base(int32_t bx, int32_t by, int32_t x1, int32_t y1
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)
{
int32_t x1, y1, x2, y2;
x1 = halfxdim16+dax-(Bstrlen(text)<<1);
y1 = midydim16+day-4;
x2 = x1 + (Bstrlen(text)<<2)+2;
y2 = y1 + 7;
if ((x1 > 3) && (x2 < xdim) && (y1 > 1) && (y2 < ydim16))
{
printext16(x1,y1, col,backcol, text,1);
drawline16(x1-1,y1-1, x2-3,y1-1, backcol);
drawline16(x1-1,y2+1, x2-3,y2+1, backcol);
drawline16(x1-2,y1, x1-2,y2, backcol);
drawline16(x2-2,y1, x2-2,y2, backcol);
drawline16(x2-3,y1, x2-3,y2, backcol);
}
}
// backup highlighted sectors with sprites as mapinfo for later restoration
// return values:
// -1: highlightsectorcnt<=0
@ -1488,9 +1509,7 @@ static void duplicate_selected_sectors()
{
// first, make red lines of old selected sectors, effectively
// restoring the original state
startwall = sector[highlightsector[i]].wallptr;
endwall = startwall+sector[highlightsector[i]].wallnum-1;
for (j=startwall; j<=endwall; j++)
for (WALLS_OF_SECTOR(highlightsector[i], j))
{
if (wall[j].nextwall >= 0)
checksectorpointer(wall[j].nextwall,wall[j].nextsector);
@ -1621,29 +1640,11 @@ static void sideview_filter_keys()
{
switch (i)
{
#if 0
case 0x01: // esc
case 0x10: case 0x11: // q,w
case 0x1e: case 0x2c: // a.z
case 0x2a: case 0x36: // shift
case 0xc8: case 0xcb: case 0xd0: case 0xcd: // arrow keys
case 0x3b: case 0x3c: case 0x3d: case 0x3e: // f1,f2,f3,f4
case 0x3f: case 0x40: case 0x43: case 0x58: // f5,f6,f9,f12
case 0x0f: case 0x29: // tab, `
case 0x22: // g
case 0x9c: // KPENTER
break;
default:
if (!(eitherCTRL && (keystatus[0x2d] || keystatus[0x14]))) // Ctrl-X, Ctrl-T
keystatus[i] = 0;
break;
#else
case 0xd2: case 0xd3: // ins, del
case 0x2e: case 0x39: // c, space
case 0xb8: // ralt
keystatus[i] = 0;
break;
#endif
}
}
}
@ -1696,7 +1697,7 @@ void overheadeditor(void)
searchy = clamp(scale(searchy,ydim2d-STATUS2DSIZ2,ydimgame), 8, ydim2d-STATUS2DSIZ-8-1);
oposz = pos.z;
begindrawing(); //{{{
begindrawing(); //{{{
CLEARLINES2D(0, ydim, 0);
@ -1712,7 +1713,8 @@ void overheadeditor(void)
// drawline16(0,ydim-1-20,xdim-1,ydim-1-20,1);
// drawline16(256,ydim-1-20,256,ydim-1,1);
ydim16 = ydim-STATUS2DSIZ2;
enddrawing(); //}}}
enddrawing(); //}}}
pag = 0;
cursectorhighlight = -1;
@ -1921,17 +1923,15 @@ void overheadeditor(void)
dax = 0; //Get average point of sector
day = 0;
startwall = sector[i].wallptr;
endwall = startwall + sector[i].wallnum - 1;
for (j=startwall; j<=endwall; j++)
for (WALLS_OF_SECTOR(i, j))
{
dax += wall[j].x;
day += wall[j].y;
}
if (endwall > startwall)
if (sector[i].wallnum > 0)
{
dax /= (endwall-startwall+1);
day /= (endwall-startwall+1);
dax /= sector[i].wallnum;
day /= sector[i].wallnum;
}
if (m32_sideview)
@ -1940,20 +1940,7 @@ void overheadeditor(void)
if (m32_sideview)
day += vdisp;
x1 = halfxdim16+dax-(Bstrlen(dabuffer)<<1);
y1 = midydim16+day-4;
x2 = x1 + (Bstrlen(dabuffer)<<2)+2;
y2 = y1 + 7;
if ((x1 > 3) && (x2 < xdim) && (y1 > 1) && (y2 < ydim16))
{
printext16(x1,y1,editorcolors[0],editorcolors[7],dabuffer,1);
drawline16(x1-1,y1-1, x2-3,y1-1, editorcolors[7]);
drawline16(x1-1,y2+1, x2-3,y2+1, editorcolors[7]);
drawline16(x1-2,y1, x1-2,y2, editorcolors[7]);
drawline16(x2-2,y1, x2-2,y2, editorcolors[7]);
drawline16(x2-3,y1, x2-3,y2, editorcolors[7]);
}
drawsmalllabel(dabuffer, editorcolors[0], editorcolors[7], dax, day);
}
}
}
@ -1975,6 +1962,7 @@ void overheadeditor(void)
for (wal=&wall[i]; i>=0; i--,wal--)
{
if (zoom < 768 && !(wal->cstat & (1<<14))) continue;
//Get average point of wall
dax = (wal->x+wall[wal->point2].x)>>1;
day = (wal->y+wall[wal->point2].y)>>1;
@ -1987,21 +1975,7 @@ void overheadeditor(void)
if (m32_sideview)
day += getscreenvdisp(getflorzofslope(sectorofwall(i), dax,day)-pos.z, zoom);
x1 = halfxdim16+dax-(Bstrlen(dabuffer)<<1);
y1 = midydim16+day-4;
x2 = x1 + (Bstrlen(dabuffer)<<2)+2;
y2 = y1 + 7;
if ((x1 > 3) && (x2 < xdim) && (y1 > 1) && (y2 < ydim16))
{
printext16(x1,y1,editorcolors[0],editorcolors[31],dabuffer,1);
drawline16(x1-1,y1-1, x2-3,y1-1, editorcolors[31]);
drawline16(x1-1,y2+1, x2-3,y2+1, editorcolors[31]);
drawline16(x1-2,y1, x1-2,y2, editorcolors[31]);
drawline16(x2-2,y1, x2-2,y2, editorcolors[31]);
drawline16(x2-3,y1, x2-3,y2, editorcolors[31]);
}
drawsmalllabel(dabuffer, editorcolors[0], editorcolors[31], dax, day);
}
}
}
@ -2031,12 +2005,6 @@ void overheadeditor(void)
if (m32_sideview)
day += getscreenvdisp(sprite[i].z-pos.z, zoom);
x1 = halfxdim16+dax-(Bstrlen(dabuffer)<<1);
y1 = midydim16+day-4;
x2 = x1 + (Bstrlen(dabuffer)<<2)+2;
y2 = y1 + 7;
if ((x1 > 3) && (x2 < xdim) && (y1 > 1) && (y2 < ydim16))
{
int32_t blocking = (sprite[i].cstat&1);
@ -2047,18 +2015,12 @@ void overheadeditor(void)
if ((i == pointhighlight-16384) && (totalclock & 32))
col += (2<<2);
printext16(x1,y1,editorcolors[0],editorcolors[col],dabuffer,1);
drawline16(x1-1,y1-1, x2-3,y1-1, editorcolors[col]);
drawline16(x1-1,y2+1, x2-3,y2+1, editorcolors[col]);
drawline16(x1-2,y1, x1-2,y2, editorcolors[col]);
drawline16(x2-2,y1, x2-2,y2, editorcolors[col]);
drawline16(x2-3,y1, x2-3,y2, editorcolors[col]);
drawsmalllabel(dabuffer, editorcolors[0], editorcolors[col], dax, day);
}
}
j--;
}
i++;
}
}
@ -2099,16 +2061,25 @@ void overheadeditor(void)
if (joinsector[0] >= 0)
col = editorcolors[11];
if (numcorruptthings>0 && (pointhighlight&16384)==0)
if (numcorruptthings>0)
{
for (i=0; i<numcorruptthings; i++)
if ((corruptthings[i]&CORRUPT_MASK)==CORRUPT_WALL &&
static char cbuf[64];
if ((pointhighlight&16384)==0)
{
for (i=0; i<numcorruptthings; i++)
if ((corruptthings[i]&CORRUPT_MASK)==CORRUPT_WALL &&
(corruptthings[i]&(MAXWALLS-1))==pointhighlight)
{
col = editorcolors[13];
printext16(searchx+6,searchy-6-8,editorcolors[13],editorcolors[0],"corrupt wall",0);
break;
}
{
col = editorcolors[13];
printext16(searchx+6,searchy-6-8,editorcolors[13],editorcolors[0],"corrupt wall",0);
break;
}
}
Bsprintf(cbuf, "Map corrupt (level %d): %s%d errors", corruptlevel,
numcorruptthings>=MAXCORRUPTTHINGS ? ">=":"", numcorruptthings);
printext16(8,8, editorcolors[13],editorcolors[0],cbuf,0);
}
if ((keystatus[0x36] || keystatus[0xb8]) && !eitherCTRL) // RSHIFT || RALT
@ -2144,6 +2115,7 @@ void overheadeditor(void)
else
drawline16base(halfxdim16+x2,midydim16+y2, 0,0, 0,0, editorcolors[5]);
}
enddrawing(); //}}}
OSD_Draw();
@ -2167,9 +2139,7 @@ void overheadeditor(void)
for (i=0; i<highlightsectorcnt; i++)
{
startwall = sector[highlightsector[i]].wallptr;
endwall = startwall+sector[highlightsector[i]].wallnum-1;
for (j=startwall; j<=endwall; j++)
for (WALLS_OF_SECTOR(highlightsector[i], j))
{
dax += wall[j].x;
day += wall[j].y;
@ -2388,9 +2358,7 @@ void overheadeditor(void)
day = 0;
for (i=0; i<highlightsectorcnt; i++)
{
startwall = sector[highlightsector[i]].wallptr;
endwall = startwall+sector[highlightsector[i]].wallnum-1;
for (j=startwall; j<=endwall; j++)
for (WALLS_OF_SECTOR(highlightsector[i], j))
{
dax += wall[j].x;
day += wall[j].y;
@ -2413,9 +2381,7 @@ void overheadeditor(void)
for (i=0; i<highlightsectorcnt; i++)
{
startwall = sector[highlightsector[i]].wallptr;
endwall = startwall+sector[highlightsector[i]].wallnum-1;
for (j=startwall; j<=endwall; j++)
for (WALLS_OF_SECTOR(highlightsector[i], j))
{
if (k == 0)
{
@ -2754,24 +2720,49 @@ void overheadeditor(void)
}
else
{
int32_t didmakered = (highlightsectorcnt<0);
int32_t didmakered = (highlightsectorcnt<0), hadouterpoint=0;
int16_t tmprefsect;
for (i=0; i<highlightsectorcnt; i++)
{
startwall = sector[highlightsector[i]].wallptr;
endwall = startwall+sector[highlightsector[i]].wallnum-1;
for (j=startwall; j<=endwall; j++)
for (WALLS_OF_SECTOR(highlightsector[i], j))
{
if (wall[j].nextwall >= 0)
checksectorpointer(wall[j].nextwall,wall[j].nextsector);
didmakered |= !!checksectorpointer((int16_t)j,highlightsector[i]);
if (!didmakered)
{
updatesectorexclude(wall[j].x, wall[j].y, &tmprefsect, hlsectorbitmap);
if (tmprefsect<0)
hadouterpoint = 1;
}
}
}
while (!didmakered && newnumwalls<0) // if
if (!didmakered && !hadouterpoint && newnumwalls<0)
{
int32_t tmpnumwalls=0, refwall, n;
int16_t refsect, ignore;
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<bytesperline*(ydim-STATUS2DSIZ2); i++, cp++)
if (*cp==greycol)
*cp = blackcol;
else if (*cp != blackcol)
*cp = greycol;
enddrawing();
showframe(1);
didmakered |= !ask_if_sure("Insert outer loop and make red walls?", 0);
clearkeys();
}
while (!didmakered && !hadouterpoint && newnumwalls<0) // if
{
int32_t tmpnumwalls=0, refwall;
uint8_t *visitedwall = Bcalloc((numwalls+7)>>3,1);
if (!visitedwall)
@ -2785,118 +2776,125 @@ void overheadeditor(void)
for (i=0; i<highlightsectorcnt; i++)
{
startwall = sector[highlightsector[i]].wallptr;
endwall = startwall+sector[highlightsector[i]].wallnum-1;
for (j=startwall; j<=endwall; j++)
if (wall[j].nextwall<0 && !(visitedwall[j>>3]&(1<<(j&7))))
for (WALLS_OF_SECTOR(highlightsector[i], j))
{
int16_t refsect, ignore;
int32_t n;
if (wall[j].nextwall>=0 || (visitedwall[j>>3]&(1<<(j&7))))
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
{
n=tmpnumwalls;
refwall = j;
k = numwalls;
if (j!=refwall && visitedwall[j>>3]&(1<<(j&7)))
ignore = 1;
visitedwall[j>>3] |= (1<<(j&7));
ignore = 0;
refsect = -1;
updatesectorexclude(wall[j].x, wall[j].y, &refsect, hlsectorbitmap);
if (refsect<0)
goto outtathis;
do
{
if (j!=refwall && visitedwall[j>>3]&(1<<(j&7)))
ignore = 1;
visitedwall[j>>3] |= (1<<(j&7));
if (inside(wall[j].x, wall[j].y, refsect)!=1)
ignore = 1;
if (!ignore)
{
if (k>=MAXWALLS)
{
message("Wall limits exceeded while trying to trace outer loop.");
goto outtathis;
}
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 trying to trace outer loop: j!=refwall");
goto outtathis;
}
if (inside(wall[j].x, wall[j].y, refsect)!=1)
ignore = 1;
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)
if (k>=MAXWALLS)
{
int16_t begwalltomove = sector[refsect].wallptr+sector[refsect].wallnum;
flipwalls(numwalls, newnumwalls);
sector[refsect].wallnum += n;
if (refsect != numsectors-1)
{
walltype *tmpwall = Bmalloc(n * sizeof(walltype));
if (!tmpwall)
{
message("out of memory!");
goto outtathis;
}
for (m=0; m<numwalls; m++)
{
if (wall[m].nextwall >= begwalltomove)
wall[m].nextwall += n;
}
for (m=refsect+1; m<numsectors; m++)
sector[m].wallptr += n;
for (m=begwalltomove; m<numwalls; m++)
wall[m].point2 += n;
for (m=numwalls; m<newnumwalls; m++)
wall[m].point2 += (begwalltomove-numwalls);
Bmemcpy(tmpwall, &wall[numwalls], n*sizeof(walltype));
Bmemmove(&wall[begwalltomove+n], &wall[begwalltomove], (numwalls-begwalltomove)*sizeof(walltype));
Bmemcpy(&wall[begwalltomove], tmpwall, n*sizeof(walltype));
Bfree(tmpwall);
}
numwalls = newnumwalls;
newnumwalls = -1;
message("Attached new inner loop to sector %d", refsect);
for (m=begwalltomove; m<begwalltomove+n; m++)
checksectorpointer(m, refsect);
message("Wall limits exceeded while tracing outer loop.");
goto outtathis;
}
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)
{
walltype *tmpwall = Bmalloc(n * sizeof(walltype));
if (!tmpwall)
{
message("out of memory!");
ExtUnInit();
uninitsystem();
exit(1);
}
for (m=0; m<numwalls; m++)
{
if (wall[m].nextwall >= begwalltomove)
wall[m].nextwall += n;
}
for (m=refsect+1; m<numsectors; m++)
sector[m].wallptr += n;
for (m=begwalltomove; m<numwalls; m++)
wall[m].point2 += n;
for (m=numwalls; m<newnumwalls; m++)
wall[m].point2 += (begwalltomove-numwalls);
Bmemcpy(tmpwall, &wall[numwalls], n*sizeof(walltype));
Bmemmove(&wall[begwalltomove+n], &wall[begwalltomove], (numwalls-begwalltomove)*sizeof(walltype));
Bmemcpy(&wall[begwalltomove], tmpwall, n*sizeof(walltype));
Bfree(tmpwall);
}
numwalls = newnumwalls;
newnumwalls = -1;
for (m=begwalltomove; m<begwalltomove+n; m++)
checksectorpointer(m, refsect);
message("Attached new inner loop to sector %d", refsect);
}
}
}
}
outtathis:
newnumwalls = -1;
Bfree(visitedwall);
break; // --|
} // <---------/
@ -2926,10 +2924,8 @@ outtathis:
for (i=0; i<numsectors; i++)
{
startwall = sector[i].wallptr;
endwall = startwall + sector[i].wallnum;
bad = 0;
for (j=startwall; j<endwall; j++)
for (WALLS_OF_SECTOR(i, j))
{
if (wall[j].x < highlightx1) bad = 1;
if (wall[j].x > highlightx2) bad = 1;
@ -3121,9 +3117,7 @@ SKIP:
for (i=0; i<highlightsectorcnt; i++)
{
startwall = sector[highlightsector[i]].wallptr;
endwall = startwall+sector[highlightsector[i]].wallnum-1;
for (j=startwall; j<=endwall; j++)
for (WALLS_OF_SECTOR(highlightsector[i], j))
{ wall[j].x += dax; wall[j].y += day; }
for (j=headspritesect[highlightsector[i]]; j>=0; j=nextspritesect[j])
@ -3221,21 +3215,21 @@ SKIP:
vec.z = sprite[daspr].z;
if (setsprite(daspr, &vec) == -1 && osec>=0)
Bmemcpy(&sprite[daspr], &ovec, sizeof(vec3_t));
/*
daz = ((tilesizy[sprite[daspr].picnum]*sprite[daspr].yrepeat)<<2);
#if 0
daz = ((tilesizy[sprite[daspr].picnum]*sprite[daspr].yrepeat)<<2);
for (i=0; i<numsectors; i++)
if (inside(dax,day,i) == 1)
if (sprite[daspr].z >= getceilzofslope(i,dax,day))
if (sprite[daspr].z-daz <= getflorzofslope(i,dax,day))
{
sprite[daspr].x = dax;
sprite[daspr].y = day;
if (sprite[daspr].sectnum != i)
changespritesect(daspr,(int16_t)i);
break;
}
*/
for (i=0; i<numsectors; i++)
if (inside(dax,day,i) == 1)
if (sprite[daspr].z >= getceilzofslope(i,dax,day))
if (sprite[daspr].z-daz <= getflorzofslope(i,dax,day))
{
sprite[daspr].x = dax;
sprite[daspr].y = day;
if (sprite[daspr].sectnum != i)
changespritesect(daspr,(int16_t)i);
break;
}
#endif
}
}
asksave = 1;
@ -3312,8 +3306,8 @@ SKIP:
drawlinepat = 0x11111111;
if (y1 != INT_MAX)
drawline16base(halfxdim16,midydim16, 0,0, 0,y1, editorcolors[14]);
else
drawline16base(halfxdim16,midydim16, 0,0, 0,getscreenvdisp(-pos.z, zoom), editorcolors[14]);
// else
// drawline16base(halfxdim16,midydim16, 0,0, 0,getscreenvdisp(-pos.z, zoom), editorcolors[14]);
drawlinepat = opat;
}
@ -3324,7 +3318,7 @@ SKIP:
else if ((oldmousebstatus&6) > 0)
updatesectorz(pos.x,pos.y,pos.z,&cursectnum);
if (circlewall != -1 && (keystatus[0x4a] || ((bstatus&32) && !eitherCTRL))) // -
if (circlewall != -1 && (keystatus[0x4a] || ((bstatus&32) && !eitherCTRL))) // -, mousewheel down
{
if (circlepoints > 1)
circlepoints--;
@ -3332,7 +3326,7 @@ SKIP:
mouseb &= ~32;
bstatus &= ~32;
}
if (circlewall != -1 && (keystatus[0x4e] || ((bstatus&16) && !eitherCTRL))) // +
if (circlewall != -1 && (keystatus[0x4e] || ((bstatus&16) && !eitherCTRL))) // +, mousewheel up
{
if (circlepoints < 63)
circlepoints++;
@ -3380,18 +3374,18 @@ SKIP:
_printmessage16("Sideview angle: %d", (int32_t)m32_sideang);
}
if (m32_sideview && keystatus[0x2a]) // LShift
if (m32_sideview && (keystatus[0x2a] || (bstatus&(16|32)))) // LShift
{
if (DOWN_BK(MOVEUP) && m32_sideelev < 512)
if ((DOWN_BK(MOVEUP) || (bstatus&16)) && m32_sideelev < 512)
{
m32_sideelev += synctics<<1;
m32_sideelev += synctics<<(1+!!(bstatus&16));
if (m32_sideelev > 512)
m32_sideelev = 512;
_printmessage16("Sideview elevation: %d", m32_sideelev);
}
if (DOWN_BK(MOVEDOWN) && m32_sideelev > 0)
if ((DOWN_BK(MOVEDOWN) || (bstatus&32)) && m32_sideelev > 0)
{
m32_sideelev -= synctics<<1;
m32_sideelev -= synctics<<(1+!!(bstatus&32));
if (m32_sideelev < 0)
m32_sideelev = 0;
_printmessage16("Sideview elevation: %d", m32_sideelev);
@ -3399,31 +3393,30 @@ SKIP:
}
else
{
int32_t didzoom=0;
if ((DOWN_BK(MOVEUP) || (bstatus&16)) && zoom < 65536)
{
zoom += synctics*(zoom>>4);
if (zoom < 24) zoom += 2;
if ((bstatus&16) && eitherALT)
{
searchx = halfxdim16;
searchy = midydim16;
pos.x = mousxplc;
pos.y = mousyplc;
}
if (zoom > 65536) zoom = 65536;
_printmessage16("Zoom: %d",zoom);
didzoom = 1;
}
if ((DOWN_BK(MOVEDOWN) || (bstatus&32)) && zoom > 8)
{
zoom -= synctics*(zoom>>4);
if ((bstatus&32) && eitherALT)
didzoom = 1;
}
if (didzoom)
{
if (eitherALT)
{
searchx = halfxdim16;
searchy = midydim16;
pos.x = mousxplc;
pos.y = mousyplc;
}
if (zoom < 8) zoom = 8;
zoom = clamp(zoom, 8, 65536);
_printmessage16("Zoom: %d",zoom);
}
}
@ -3500,9 +3493,7 @@ SKIP:
for (k=0; k<2; k++)
{
startwall = sector[joinsector[k]].wallptr;
endwall = startwall + sector[joinsector[k]].wallnum - 1;
for (j=startwall; j<=endwall; j++)
for (WALLS_OF_SECTOR(joinsector[k], j))
{
if (wall[j].cstat == 255)
continue;
@ -3568,9 +3559,7 @@ SKIP:
for (k=0; k<2; k++)
{
startwall = sector[joinsector[k]].wallptr;
endwall = startwall + sector[joinsector[k]].wallnum - 1;
for (j=startwall; j<=endwall; j++)
for (WALLS_OF_SECTOR(joinsector[k], j))
{
wall[j].nextwall = -1;
wall[j].nextsector = -1;
@ -3938,9 +3927,7 @@ SKIP:
{
//check if first point at point of sector
m = -1;
startwall = sector[i].wallptr;
endwall = startwall + sector[i].wallnum - 1;
for (k=startwall; k<=endwall; k++)
for (WALLS_OF_SECTOR(i, k))
if (wall[k].x==wall[numwalls].x && wall[k].y==wall[numwalls].y)
{
m = k;
@ -4493,10 +4480,8 @@ SKIP:
}
for (i=0; i<numsectors; i++)
{
startwall = sector[i].wallptr;
endwall = startwall + sector[i].wallnum;
for (j=startwall; j<endwall; j++)
checksectorpointer((int16_t)j,(int16_t)i);
for (WALLS_OF_SECTOR(i, j))
checksectorpointer(j, i);
}
printmessage16("ALL POINTERS CHECKED!");
asksave = 1;
@ -4861,7 +4846,7 @@ CANCEL:
}
else if (ch == 'a' || ch == 'A') //A
{
int32_t corrupt = CheckMapCorruption(4);
int32_t corrupt = CheckMapCorruption(4, 0);
bad = 0;
@ -4950,7 +4935,7 @@ CANCEL:
bad = 0;
if (CheckMapCorruption(4)>=4)
if (CheckMapCorruption(4, 0)>=4)
if (!ask_if_sure("Map is corrupt. Are you sure you want to save?", 0))
break;
@ -4990,7 +4975,7 @@ CANCEL:
{
//QUIT!
int32_t corrupt = CheckMapCorruption(4);
int32_t corrupt = CheckMapCorruption(4, 0);
if (ask_if_sure(corrupt<4?"Save changes?":"Map corrupt. Save changes?", corrupt<4?0:1))
SaveBoard(NULL, 0);
@ -5005,10 +4990,10 @@ CANCEL:
goto CANCEL;
}
ExtUnInit();
clearfilenames();
uninittimer();
uninitinput();
ExtUnInit();
uninitengine();
exit(0);
}
@ -5029,9 +5014,7 @@ CANCEL:
for (i=0; i<highlightsectorcnt; i++)
{
startwall = sector[highlightsector[i]].wallptr;
endwall = startwall+sector[highlightsector[i]].wallnum-1;
for (j=startwall; j<=endwall; j++)
for (WALLS_OF_SECTOR(highlightsector[i], j))
{
if (wall[j].nextwall >= 0)
checksectorpointer(wall[j].nextwall,wall[j].nextsector);
@ -5043,16 +5026,16 @@ CANCEL:
if (setgamemode(fullscreen,xdimgame,ydimgame,bppgame) < 0)
{
initprintf("%d * %d not supported in this graphics mode\n",xdim,ydim);
ExtUnInit();
uninitinput();
uninittimer();
initprintf("%d * %d not supported in this graphics mode\n",xdim,ydim);
uninitsystem();
clearfilenames();
exit(0);
}
setbrightness(GAMMA_CALC,palette,0);
setbrightness(GAMMA_CALC,0,0);
pos.z = oposz;
@ -5074,6 +5057,7 @@ static int32_t ask_if_sure(const char *query, int32_t quit_is_yes)
_printmessage16("%s", query);
showframe(1);
bflushchars();
while ((keystatus[1]|keystatus[0x2e]) == 0)
{
if (handleevents())
@ -5128,7 +5112,7 @@ const char *SaveBoard(const char *fn, uint32_t flags)
if ((flags&1)==0)
ExtSaveMap(f);
if (ret)
if (!ret)
return f;
else
return NULL;
@ -5181,7 +5165,7 @@ int32_t LoadBoard(const char *filename, uint32_t flags)
if (mapversion < 7) message("Map %s loaded successfully and autoconverted to V7!",boardfilename);
else
{
i = CheckMapCorruption(4);
i = CheckMapCorruption(4, 0);
message("Loaded map %s %s",boardfilename, i==0?"successfully":
(i<4 ? "(moderate corruption)" : "(HEAVY corruption)"));
}
@ -5291,7 +5275,11 @@ int32_t getpointhighlight(int32_t xplc, int32_t yplc, int32_t point)
}
if (dst <= dist)
dist = dst, closest = j;
{
// prefer white walls
if (dist<dist || closest==-1 || (wall[j].nextwall>=0)-(wall[closest].nextwall>=0) <= 0)
dist = dst, closest = j;
}
}
if (zoom >= 256)
@ -5538,7 +5526,6 @@ static int32_t deletesector(int16_t sucksect)
}
numsectors--;
j = endwall-startwall+1;
for (i=startwall; i<=endwall; i++)
if (wall[i].nextwall != -1)
{
@ -5546,6 +5533,7 @@ static int32_t deletesector(int16_t sucksect)
NEXTWALL(i).nextsector = -1;
}
j = endwall-startwall+1;
movewalls(startwall,-j);
for (i=0; i<numwalls; i++)
if (wall[i].nextwall >= startwall)
@ -6064,16 +6052,14 @@ static int32_t menuselect(void)
if (!findfileshigh)
findfileshigh=findfiles;
begindrawing();
_printmessage16("Select map file with arrow keys and enter.");
enddrawing();
ydim16 = ydim-STATUS2DSIZ2;
listsize = (ydim16-32)/9;
do
{
begindrawing();
begindrawing(); //{{{
CLEARLINES2D(0, ydim16, 0);
@ -6138,7 +6124,8 @@ static int32_t menuselect(void)
}
}
}
enddrawing();
enddrawing(); //}}}
showframe(1);
keystatus[0xcb] = 0;
@ -6572,7 +6559,7 @@ int32_t loadnames(void)
}
else if (comment)continue;
badline:
initprintf("Error: Invalid statement found at character %d on line %d\n", (p-buffer), line-1);
initprintf("Error: Invalid statement found at character %d on line %d\n", (int32_t)(p-buffer), line-1);
}
initprintf("Read %d lines, loaded %d names.\n", line, syms);
@ -6934,12 +6921,10 @@ void _printmessage16(const char *fmt, ...)
clearministatbar16();
begindrawing();
// ybase = (overridepm16y >= 0) ? ydim-overridepm16y : ydim-STATUS2DSIZ+128-8;
ybase = ydim-STATUS2DSIZ+128-8;
printext16(/*(overridepm16y >= 0) ? 200L-24 :*/ 8, ybase+8, whitecol, -1, snotbuf, 0);
enddrawing();
}
void printmessage256(int32_t x, int32_t y, const char *name)

View file

@ -69,7 +69,7 @@ static int32_t lockrecip[200];
static char toupperlookup[256];
static void reportandexit(char *errormessage);
static void reportandexit(const char *errormessage);
extern char pow2char[8];
@ -226,7 +226,7 @@ void agecache(void)
}
}
static void reportandexit(char *errormessage)
static void reportandexit(const char *errormessage)
{
int32_t i, j;
@ -841,7 +841,7 @@ void kclose(int32_t handle)
filehan[handle] = -1;
}
static int32_t klistaddentry(CACHE1D_FIND_REC **rec, char *name, int32_t type, int32_t source)
static int32_t klistaddentry(CACHE1D_FIND_REC **rec, const char *name, int32_t type, int32_t source)
{
CACHE1D_FIND_REC *r = NULL, *attach = NULL;

View file

@ -707,7 +707,7 @@ int32_t Bclosedir(BDIR *dir)
}
char *Bstrtoken(char *s, char *delim, char **ptrptr, int32_t chop)
char *Bstrtoken(char *s, const char *delim, char **ptrptr, int32_t chop)
{
char *p, *start;

View file

@ -7,6 +7,7 @@
#include "build.h"
#include "compat.h"
#include "engine_priv.h"
#include "baselayer.h"
#include "scriptfile.h"
#include "cache1d.h"
@ -46,6 +47,7 @@ enum scripttoken_t
T_FPS,
T_FLAGS,
T_PAL,
T_BASEPAL,
T_DETAIL,
T_GLOW,
T_SPECULAR,
@ -80,7 +82,7 @@ enum scripttoken_t
T_TILEFROMTEXTURE, T_XOFFSET, T_YOFFSET
};
typedef struct { char *text; int32_t tokenid; } tokenlist;
typedef struct { const char *text; int32_t tokenid; } tokenlist;
static int32_t getatoken(scriptfile *sf, const tokenlist *tl, int32_t ntokens)
{
@ -1432,13 +1434,16 @@ static int32_t defsparser(scriptfile *script)
case T_HIGHPALOOKUP:
{
char *highpaltokptr = script->ltextptr;
int32_t pal=-1, oldpathsearchmode, fd;
int32_t basepal=-1, pal=-1, oldpathsearchmode;
char *fn = NULL, *tfn = NULL;
char *highpalend;
#ifdef POLYMER
int32_t fd;
char *highpaldata;
#endif
static const tokenlist highpaltokens[] =
{
{ "basepal", T_BASEPAL },
{ "pal", T_PAL },
{ "file", T_FILE }
};
@ -1448,12 +1453,20 @@ static int32_t defsparser(scriptfile *script)
{
switch (getatoken(script,highpaltokens,sizeof(highpaltokens)/sizeof(tokenlist)))
{
case T_BASEPAL:
scriptfile_getsymbol(script,&basepal); break;
case T_PAL:
scriptfile_getsymbol(script,&pal); break;
case T_FILE:
scriptfile_getstring(script,&fn); break;
}
}
if ((unsigned)basepal >= ((unsigned)basepalcount))
{
initprintf("Error: missing or invalid 'base palette number' for highpalookup definition "
"near line %s:%d\n", script->filename, scriptfile_getlinum(script,highpaltokptr));
break;
}
if ((unsigned)pal >= ((unsigned)MAXPALOOKUPS - RESERVEDPALS))
{
@ -1461,6 +1474,7 @@ static int32_t defsparser(scriptfile *script)
"line %s:%d\n", script->filename, scriptfile_getlinum(script,highpaltokptr));
break;
}
if (!fn)
{
initprintf("Error: missing 'file name' for highpalookup definition near line %s:%d\n",
@ -1486,6 +1500,7 @@ static int32_t defsparser(scriptfile *script)
else Bfree(tfn);
pathsearchmode = oldpathsearchmode;
#ifdef POLYMER
fd = kopen4load(fn, 0);
// load the highpalookup and send it to polymer
@ -1498,11 +1513,11 @@ static int32_t defsparser(scriptfile *script)
filesize = kfilelength(fd);
filebuf = Bmalloc(filesize);
if (!filebuf) { Bfree(highpaldata); break; }
if (!filebuf) { kclose(fd); Bfree(highpaldata); break; }
klseek(fd, 0, SEEK_SET);
if (kread(fd, filebuf, filesize)!=filesize)
{ Bfree(highpaldata); initprintf("Error: didn't read all of '%s'.\n", fn); break; }
{ kclose(fd); Bfree(highpaldata); initprintf("Error: didn't read all of '%s'.\n", fn); break; }
kclose(fd);
kpgetdim(filebuf, filesize, &xsiz, &ysiz);
@ -1521,9 +1536,10 @@ static int32_t defsparser(scriptfile *script)
{ Bfree(highpaldata); initprintf("Error: failed rendering '%s'.\n", fn); break; }
}
polymer_definehighpalookup(pal, highpaldata);
polymer_definehighpalookup(basepal, pal, highpaldata);
Bfree(highpaldata);
#endif
}
break;
case T_TINT:

View file

@ -155,7 +155,7 @@ char britable[16][256]; // JBF 20040207: full 8bit precision
extern char textfont[2048], smalltextfont[2048];
static char kensmessage[128];
char *engineerrstr = "No error";
const char *engineerrstr = "No error";
int32_t showfirstwall=0;
int32_t showheightindicators=2;
@ -612,7 +612,7 @@ int32_t clipmapinfo_load(const char *filename)
if (wall[w].lotag > wall[w].hitag)
swapshort(&wall[w].lotag, &wall[w].hitag);
for (ii=wall[w].lotag; ii<MAXTILES; ii++)
for (ii=wall[w].lotag; ii<wall[w].hitag; ii++)
tempictoidx[ii] = numclipmaps;
}
else if (wall[w].lotag>0)
@ -758,6 +758,11 @@ int32_t checksectorpointer(int16_t i, int16_t sectnum)
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.
// The nextwall relation should be definitely one-to-one at all times!
if (wall[k].nextwall>=0 && wall[k].nextwall != i)
continue;
if (sectnum != -2) // -2 means dry run
{
wall[i].nextsector = j;
@ -1193,6 +1198,11 @@ static int32_t bakrendmode,baktile;
int32_t totalclocklock;
char apptitle[256] = "Build Engine";
uint8_t **basepaltableptr;
uint8_t basepalcount;
uint8_t curbasepal;
palette_t curpalette[256]; // the current palette, unadjusted for brightness or tint
palette_t curpalettefaded[256]; // the current palette, adjusted for brightness and tint (ie. what gets sent to the card)
palette_t palfadergb = { 0,0,0,0 };
@ -1272,7 +1282,7 @@ static void scansector(int16_t sectnum)
if ((gotsector[nextsectnum>>3]&pow2char[nextsectnum&7]) == 0)
{
tempint = x1*y2-x2*y1;
if (((unsigned)tempint+262144) < 524288)
if (((unsigned)tempint+262144) < 524288) // BXY_MAX?
if (mulscale5(tempint,tempint) <= (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
sectorborder[sectorbordercnt++] = nextsectnum;
}
@ -3110,7 +3120,8 @@ static void drawalls(int32_t bunch)
}
wallnum = thewall[z]; wal = &wall[wallnum];
nextsectnum = wal->nextsector; nextsec = &sector[nextsectnum];
nextsectnum = wal->nextsector;
nextsec = nextsectnum>=0 ? &sector[nextsectnum] : NULL;
gotswall = 0;
@ -6175,7 +6186,7 @@ int32_t preinitengine(void)
dynarray[] =
{
{ (void **) &sector, sizeof(sectortype) *MAXSECTORS },
{ (void **) &wall, sizeof(walltype) *(MAXWALLS+4) }, // +4: editor quirks
{ (void **) &wall, sizeof(walltype) *MAXWALLS }, // +1024: editor quirks. FIXME!
{ (void **) &sprite, sizeof(spritetype) *MAXSPRITES },
{ (void **) &tsprite, sizeof(spritetype) *MAXSPRITESONSCREEN },
{ (void **) &spriteext, sizeof(spriteext_t) *(MAXSPRITES+MAXUNIQHUDID) },
@ -6184,6 +6195,12 @@ int32_t preinitengine(void)
{ (void **) &state_decompress, sizeof(qlz_state_decompress) }
};
if (editstatus)
{
dynarray[1].size += 1024*sizeof(walltype);
Bprintf("FIXME: Allocating additional space beyong wall[] for editor bugs.\n");
}
for (i=0; i<(signed)(sizeof(dynarray)/sizeof(dynarray[0])); i++)
size += dynarray[i].size;
@ -6490,6 +6507,14 @@ void drawrooms(int32_t daposx, int32_t daposy, int32_t daposz,
i = globalcursectnum;
updatesector(globalposx,globalposy,&globalcursectnum);
if (globalcursectnum < 0) globalcursectnum = i;
// PK 20110123: I'm not sure what the line above is supposed to do, but 'i'
// *can* be negative, so let's just quit here in that case...
if (globalcursectnum<0)
{
enddrawing();
return;
}
}
globparaceilclip = 1;
@ -7887,7 +7912,7 @@ int32_t loadmaphack(const char *filename)
T_LIGHT,
};
static struct { char *text; int32_t tokenid; } legaltokens[] =
static struct { const char *text; int32_t tokenid; } legaltokens[] =
{
{ "sprite", T_SPRITE },
{ "angleoff", T_ANGOFF },
@ -8405,7 +8430,7 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da
setview(0L,0L,xdim-1,ydim-1);
clearallviews(0L);
setbrightness(curbrightness,palette,0);
setbrightness(curbrightness,0,0);
if (searchx < 0) { searchx = halfxdimen; searchy = (ydimen>>1); }
@ -9671,7 +9696,9 @@ int32_t lastwall(int16_t point)
}
//////////
////////// CLIPMOVE //////////
int32_t clipmoveboxtracenum = 3;
static int32_t clipsprite_try(const spritetype *spr, int32_t xmin, int32_t ymin, int32_t xmax, int32_t ymax)
{
@ -9796,17 +9823,24 @@ static int32_t clipsprite_initindex(int32_t curidx, spritetype *curspr, int32_t
return flipmul;
}
#define addclipline(dax1, day1, dax2, day2, daoval) \
{ \
if (clipnum < MAXCLIPNUM) { \
clipit[clipnum].x1 = dax1; clipit[clipnum].y1 = day1; \
clipit[clipnum].x2 = dax2; clipit[clipnum].y2 = day2; \
clipobjectval[clipnum] = daoval; \
clipnum++; \
} else if (!warned) { initprintf("!!clipnum\n"); warned=1; } \
} \
int32_t clipmoveboxtracenum = 3;
static int32_t clipmove_warned=0;
static void addclipline(int32_t dax1, int32_t day1, int32_t dax2, int32_t day2, int32_t daoval)
{
if (clipnum < MAXCLIPNUM)
{
clipit[clipnum].x1 = dax1; clipit[clipnum].y1 = day1;
clipit[clipnum].x2 = dax2; clipit[clipnum].y2 = day2;
clipobjectval[clipnum] = daoval;
clipnum++;
}
else if (!clipmove_warned)
{
initprintf("!!clipnum\n");
clipmove_warned = 1;
}
}
//
// clipmove
@ -9827,11 +9861,13 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum,
int32_t hitwall, cnt, clipyou;
spritetype *curspr=NULL; // non-NULL when handling sprite with sector-like clipping
int32_t curidx=-1, warned=0, clipspritecnt;
int32_t curidx=-1, clipspritecnt;
if (((xvect|yvect) == 0) || (*sectnum < 0)) return(0);
retval = 0;
clipmove_warned = 0;
oxvect = xvect;
oyvect = yvect;
@ -11110,13 +11146,33 @@ void setvgapalette(void)
setpalette(0,256);
}
//
// setbasepaltable
//
void setbasepaltable(uint8_t **thebasepaltable, uint8_t thebasepalcount)
{
if (thebasepalcount >= MAXBASEPALS)
thebasepalcount = MAXBASEPALS - 1;
basepaltableptr = thebasepaltable;
basepalcount = thebasepalcount;
}
//
// setbrightness
//
void setbrightness(char dabrightness, uint8_t *dapal, char noapply)
void setbrightness(char dabrightness, uint8_t dapalid, char noapply)
{
int32_t i, k, j;
uint8_t *dapal;
// uint32_t lastbright = curbrightness;
if (dapalid >= basepalcount)
dapalid = 0;
curbasepal = dapalid;
dapal = basepaltableptr[dapalid];
if (!(noapply&4))
{
@ -11514,13 +11570,10 @@ void completemirror(void)
//
// sectorofwall
//
int32_t sectorofwall(int16_t theline)
static int32_t sectorofwall_internal(int16_t theline)
{
int32_t i, gap;
if ((theline < 0) || (theline >= numwalls)) return(-1);
i = wall[theline].nextwall; if (i >= 0 && i < MAXWALLS) return(wall[i].nextsector);
gap = (numsectors>>1); i = gap;
while (gap > 1)
{
@ -11532,6 +11585,23 @@ int32_t sectorofwall(int16_t theline)
return(i);
}
int32_t sectorofwall(int16_t theline)
{
int32_t i;
if ((theline < 0) || (theline >= numwalls)) return(-1);
i = wall[theline].nextwall; if (i >= 0 && i < MAXWALLS) return(wall[i].nextsector);
return sectorofwall_internal(theline);
}
int32_t sectorofwall_noquick(int16_t theline)
{
if ((theline < 0) || (theline >= numwalls)) return(-1);
return sectorofwall_internal(theline);
}
//
// getceilzofslope

View file

@ -8,6 +8,10 @@
#define MAXNODESPERLINE 42 //Warning: This depends on MAXYSAVES & MAXYDIM!
#define MAXCLIPDIST 1024
extern uint8_t **basepaltableptr;
extern uint8_t basepalcount;
extern uint8_t curbasepal;
extern char pow2char[8];
extern int32_t pow2int[32];

View file

@ -10,6 +10,7 @@
#include "compat.h"
#include "kplib.h"
#include "hightile.h"
#include "baselayer.h"
palette_t hictinting[MAXPALOOKUPS];
@ -166,13 +167,13 @@ int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float
if (tilesizx[picnum]<=0 || tilesizy[picnum]<=0)
{
static int32_t first=1;
OSD_Printf("warning: defined hightile replacement for empty tile %d.", picnum);
initprintf("Warning: defined hightile replacement for empty tile %d.", picnum);
if (first)
{
OSD_Printf(" Maybe some tiles???.art are not loaded?");
initprintf(" Maybe some tilesXXX.art are not loaded?");
first = 0;
}
OSD_Printf("\n");
initprintf("\n");
}
//printf("Replacement [%d,%d]: %s\n", picnum, palnum, hicreplc[i]->filename);

View file

@ -23,6 +23,17 @@ int32_t curextra=MAXTILES;
// #define MODEL_POOL_SIZE 20971520
#define model_data_pool (nedpool *) 0 // take it out of the system pool
#define MIN_CACHETIME_PRINT 5
static void QuitOnFatalError(const char *msg)
{
if (msg)
initprintf("%s\n", msg);
uninitengine();
exit(1);
}
int32_t addtileP(int32_t model,int32_t tile,int32_t pallet)
{
UNREFERENCED_PARAMETER(model);
@ -443,7 +454,7 @@ static int32_t daskinloader(int32_t filh, intptr_t *fptr, int32_t *bpl, int32_t
memset(pic,0,xsiz*ysiz*sizeof(coltype));
if (kprender(picfil,picfillen,(intptr_t)pic,xsiz*sizeof(coltype),xsiz,ysiz,0,0))
{ Bfree(picfil); Bfree(pic); return -1; }
{ Bfree(picfil); Bfree(pic); return -2; }
Bfree(picfil);
cptr = &britable[gammabrightness ? 0 : curbrightness][0];
@ -773,14 +784,20 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
}
else
{
int32_t ret;
// if (cachefil >= 0) kclose(cachefil);
cachefil = -1; // the compressed version will be saved to disk
if ((filh = kopen4load(fn, 0)) < 0) return -1;
if (daskinloader(filh,&fptr,&bpl,&xsiz,&ysiz,&osizx,&osizy,&hasalpha,pal,(globalnoeffect)?0:(hictinting[pal].f&HICEFFECTMASK)))
ret=daskinloader(filh,&fptr,&bpl,&xsiz,&ysiz,&osizx,&osizy,&hasalpha,pal,(globalnoeffect)?0:(hictinting[pal].f&HICEFFECTMASK));
if (ret)
{
kclose(filh);
OSD_Printf("Failed loading skin file \"%s\"\n", fn);
OSD_Printf("Failed loading skin file \"%s\": error %d\n", fn, ret);
if (ret==-1)
QuitOnFatalError("OUT OF MEMORY in daskinloader!");
skinfile[0] = 0;
return(0);
}
@ -863,7 +880,9 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
if (willprint)
{
OSD_Printf("Load skin: p%d-e%d \"%s\"... cached... %d ms\n", pal, (globalnoeffect)?0:(hictinting[pal].f&HICEFFECTMASK), fn, getticks()-startticks);
int32_t etime = getticks()-startticks;
if (etime>=MIN_CACHETIME_PRINT)
OSD_Printf("Load skin: p%d-e%d \"%s\"... cached... %d ms\n", pal, (globalnoeffect)?0:(hictinting[pal].f&HICEFFECTMASK), fn, etime);
willprint = 0;
}
else
@ -871,7 +890,11 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
}
if (willprint)
OSD_Printf("Load skin: p%d-e%d \"%s\"... %d ms\n", pal, (globalnoeffect)?0:(hictinting[pal].f&HICEFFECTMASK), fn, getticks()-startticks);
{
int32_t etime = getticks()-startticks;
if (etime>=MIN_CACHETIME_PRINT)
OSD_Printf("Load skin: p%d-e%d \"%s\"... %d ms\n", pal, (globalnoeffect)?0:(hictinting[pal].f&HICEFFECTMASK), fn, etime);
}
return(*texidx);
}
@ -1253,11 +1276,7 @@ static md2model_t *md2load(int32_t fil, const char *filnam)
m3->maxdepths = Bmalloc(sizeof(float) * s->numtris);
if (!m3->indexes || !m3->vindexes || !m3->maxdepths)
{
initprintf("OUT OF MEMORY in md2load!\n");
uninitengine();
exit(1);
}
QuitOnFatalError("OUT OF MEMORY in md2load!");
m3->vbos = NULL;
@ -1479,11 +1498,7 @@ static md3model_t *md3load(int32_t fil)
m->maxdepths = Bmalloc(sizeof(float) * maxtrispersurf);
if (!m->indexes || !m->vindexes || !m->maxdepths)
{
initprintf("OUT OF MEMORY in md3load!\n");
uninitengine();
exit(1);
}
QuitOnFatalError("OUT OF MEMORY in md3load!");
m->vbos = NULL;
@ -1681,11 +1696,7 @@ int md3postload_polymer(md3model_t *m)
numtris = Bcalloc(s->numverts, sizeof(int));
if (!s->geometry || !numtris)
{
initprintf("OUT OF MEMORY in md3postload_polymer!\n");
uninitengine();
exit(1);
}
QuitOnFatalError("OUT OF MEMORY in md3postload_polymer!");
verti = 0;
while (verti < (m->head.numframes * s->numverts))

View file

@ -57,6 +57,10 @@ DEALINGS IN THE SOFTWARE.
/* Sadly we can't include <malloc.h> as it causes a redefinition error */
extern size_t malloc_usable_size(void *);
#endif
#if defined(__APPLE__)
/* PK: for malloc_size(): */
#include <malloc/malloc.h>
#endif
#if USE_ALLOCATOR==1
#define MSPACES 1
#define ONLY_MSPACES 1

View file

@ -33,6 +33,9 @@ float pr_specularfactor = 1.0f;
int32_t pr_highpalookups = 1;
int32_t pr_ati_fboworkaround = 0;
int32_t pr_ati_nodepthoffset = 0;
#ifdef __APPLE__
int32_t pr_ati_textureformat_one = 0;
#endif
int32_t r_pr_maxlightpasses = 5; // value of the cvar (not live value), used to detect changes
@ -44,7 +47,7 @@ _prsector *prsectors[MAXSECTORS];
_prwall *prwalls[MAXWALLS];
_prsprite *prsprites[MAXSPRITES];
_prmaterial mdspritematerial;
_prhighpalookup prhighpalookups[MAXPALOOKUPS];
_prhighpalookup prhighpalookups[MAXBASEPALS][MAXPALOOKUPS];
static const GLfloat vertsprite[4 * 5] =
{
@ -319,9 +322,12 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
"uniform sampler3D highPalookupMap;\n"
"\n",
// frag_prog
" float highPalScale = 0.9921875; // for 6 bits\n"
" float highPalBias = 0.00390625;\n"
"\n"
" if (isLightingPass == 0)\n"
" result.rgb = texture3D(highPalookupMap, result.rgb).rgb;\n"
" diffuseTexel.rgb = texture3D(highPalookupMap, diffuseTexel.rgb).rgb;\n"
" result.rgb = texture3D(highPalookupMap, result.rgb * highPalScale + highPalBias).rgb;\n"
" diffuseTexel.rgb = texture3D(highPalookupMap, diffuseTexel.rgb * highPalScale + highPalBias).rgb;\n"
"\n",
},
{
@ -614,7 +620,7 @@ int32_t polymersearching;
// EXTERNAL FUNCTIONS
int32_t polymer_init(void)
{
int32_t i;
int32_t i, j;
if (pr_verbosity >= 1) OSD_Printf("Initializing Polymer subsystem...\n");
@ -676,28 +682,33 @@ int32_t polymer_init(void)
// Prime highpalookup maps
i = 0;
while (i < MAXPALOOKUPS)
while (i < MAXBASEPALS)
{
if (prhighpalookups[i].data)
j = 0;
while (j < MAXPALOOKUPS)
{
bglGenTextures(1, &prhighpalookups[i].map);
bglBindTexture(GL_TEXTURE_3D, prhighpalookups[i].map);
bglTexImage3D(GL_TEXTURE_3D, // target
0, // mip level
GL_RGBA, // internalFormat
PR_HIGHPALOOKUP_DIM, // width
PR_HIGHPALOOKUP_DIM, // height
PR_HIGHPALOOKUP_DIM, // depth
0, // border
GL_BGRA, // upload format
GL_UNSIGNED_BYTE, // upload component type
prhighpalookups[i].data); // data pointer
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
bglBindTexture(GL_TEXTURE_3D, 0);
if (prhighpalookups[i][j].data)
{
bglGenTextures(1, &prhighpalookups[i][j].map);
bglBindTexture(GL_TEXTURE_3D, prhighpalookups[i][j].map);
bglTexImage3D(GL_TEXTURE_3D, // target
0, // mip level
GL_RGBA, // internalFormat
PR_HIGHPALOOKUP_DIM, // width
PR_HIGHPALOOKUP_DIM, // height
PR_HIGHPALOOKUP_DIM, // depth
0, // border
GL_BGRA, // upload format
GL_UNSIGNED_BYTE, // upload component type
prhighpalookups[i][j].data); // data pointer
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
bglBindTexture(GL_TEXTURE_3D, 0);
}
j++;
}
i++;
}
@ -709,21 +720,26 @@ int32_t polymer_init(void)
void polymer_uninit(void)
{
int32_t i;
int32_t i, j;
polymer_freeboard();
i = 0;
while (i < MAXPALOOKUPS)
while (i < MAXBASEPALS)
{
if (prhighpalookups[i].data) {
Bfree(prhighpalookups[i].data);
prhighpalookups[i].data = NULL;
}
if (prhighpalookups[i].map) {
bglDeleteTextures(1, &prhighpalookups[i].map);
prhighpalookups[i].map = 0;
}
j = 0;
while (j < MAXPALOOKUPS)
{
if (prhighpalookups[i][j].data) {
Bfree(prhighpalookups[i][j].data);
prhighpalookups[i][j].data = NULL;
}
if (prhighpalookups[i][j].map) {
bglDeleteTextures(1, &prhighpalookups[i][j].map);
prhighpalookups[i][j].map = 0;
}
j++;
}
i++;
}
}
@ -1065,11 +1081,16 @@ void polymer_editorpick(void)
switch (searchstat) {
case 0: // wall
case 5: // botomwall
case 4: // 1-way/masked wall
searchsector = sectorofwall(num);
searchbottomwall = searchwall = num;
if (wall[num].nextwall>=0 && (wall[num].cstat&2))
searchbottomwall = wall[num].nextwall;
if (searchstat == 5) {
searchstat = 0;
if (wall[num].nextwall >= 0 && (wall[num].cstat & 2)) {
searchbottomwall = wall[num].nextwall;
}
}
break;
case 1: // floor
case 2: // ceiling
@ -1661,11 +1682,11 @@ void polymer_texinvalidate(void)
while (i >= 0);
}
void polymer_definehighpalookup(char palnum, char *data)
void polymer_definehighpalookup(char basepalnum, char palnum, char *data)
{
prhighpalookups[palnum].data = Bmalloc(PR_HIGHPALOOKUP_DATA_SIZE);
prhighpalookups[basepalnum][palnum].data = Bmalloc(PR_HIGHPALOOKUP_DATA_SIZE);
Bmemcpy(prhighpalookups[palnum].data, data, PR_HIGHPALOOKUP_DATA_SIZE);
Bmemcpy(prhighpalookups[basepalnum][palnum].data, data, PR_HIGHPALOOKUP_DATA_SIZE);
}
// CORE
@ -2769,7 +2790,8 @@ static void polymer_updatewall(int16_t wallnum)
((nwallpicnum == w->nwallpicnum) &&
(wall[nwallnum].xpanning == w->nwallxpanning) &&
(wall[nwallnum].ypanning == w->nwallypanning) &&
(wall[nwallnum].cstat == w->nwallcstat))))
(wall[nwallnum].cstat == w->nwallcstat) &&
(wall[nwallnum].shade == w->nwallshade))))
{
w->flags.uptodate = 1;
return; // screw you guys I'm going home
@ -2795,6 +2817,7 @@ static void polymer_updatewall(int16_t wallnum)
w->nwallxpanning = wall[nwallnum].xpanning;
w->nwallypanning = wall[nwallnum].ypanning;
w->nwallcstat = wall[nwallnum].cstat;
w->nwallshade = wall[nwallnum].shade;
}
}
@ -3154,22 +3177,11 @@ static void polymer_drawwall(int16_t sectnum, int16_t wallnum)
if ((w->underover & 1) && (!parallaxedfloor || (searchit == 2)))
{
if (searchit == 2) {
int16_t pickwallnum;
memcpy(oldcolor, w->wall.material.diffusemodulation, sizeof(GLubyte) * 4);
pickwallnum = wallnum;
// if the bottom of the walls are inverted
// we're going to hit the nextwall instead
// PK -- handled in polymer_editorpick(), also because there
// are maps with .nextwall==-1 but .cstat&2 (like e4l3)
// if (wall[wallnum].cstat & 2)
// pickwallnum = wall[wallnum].nextwall;
w->wall.material.diffusemodulation[0] = 0x00;
w->wall.material.diffusemodulation[1] = ((GLubyte *)(&pickwallnum))[0];
w->wall.material.diffusemodulation[2] = ((GLubyte *)(&pickwallnum))[1];
w->wall.material.diffusemodulation[0] = 0x05;
w->wall.material.diffusemodulation[1] = ((GLubyte *)(&wallnum))[0];
w->wall.material.diffusemodulation[2] = ((GLubyte *)(&wallnum))[1];
w->wall.material.diffusemodulation[3] = 0xFF;
}
@ -3825,8 +3837,8 @@ static void polymer_drawmdsprite(spritetype *tspr)
color[0] = color[1] = color[2] =
((float)(numpalookups-min(max((tspr->shade * shadescale)+m->shadeoff,0),numpalookups)))/((float)numpalookups) * 0xFF;
usinghighpal = (tspr->pal > 0 && pr_highpalookups &&
prhighpalookups[tspr->pal].map);
usinghighpal = (pr_highpalookups &&
prhighpalookups[curbasepal][tspr->pal].map);
// If that palette has a highpalookup, we'll never use tinting. We might use
// alternate skins if they exist later, though.
@ -3842,9 +3854,10 @@ static void polymer_drawmdsprite(spritetype *tspr)
}
// fullscreen tint on global palette change
if (hictinting[MAXPALOOKUPS-1].r != 255 ||
hictinting[MAXPALOOKUPS-1].g != 255 ||
hictinting[MAXPALOOKUPS-1].b != 255)
if (!usinghighpal &&
(hictinting[MAXPALOOKUPS-1].r != 255 ||
hictinting[MAXPALOOKUPS-1].g != 255 ||
hictinting[MAXPALOOKUPS-1].b != 255))
{
color[0] *= hictinting[MAXPALOOKUPS-1].r / 255.0;
color[1] *= hictinting[MAXPALOOKUPS-1].g / 255.0;
@ -3977,11 +3990,15 @@ static void polymer_drawmdsprite(spritetype *tspr)
foundpalskin = 1;
}
// If we have a global palette tint, the palskin won't do us any good
if (curbasepal)
foundpalskin = 0;
if (!foundpalskin && usinghighpal) {
// We don't have a specific skin defined for this palette
// Use the base skin instead and plug in our highpalookup map
targetpal = 0;
mdspritematerial.highpalookupmap = prhighpalookups[tspr->pal].map;
mdspritematerial.highpalookupmap = prhighpalookups[curbasepal][tspr->pal].map;
}
mdspritematerial.diffusemap =
@ -4160,6 +4177,7 @@ static void polymer_getscratchmaterial(_prmaterial* material)
static void polymer_getbuildmaterial(_prmaterial* material, int16_t tilenum, char pal, int8_t shade, int32_t cmeth)
{
pthtyp* pth;
int32_t usinghighpal = 0;
polymer_getscratchmaterial(material);
@ -4168,11 +4186,13 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
loadtile(tilenum);
// PR_BIT_HIGHPALOOKUP_MAP
if (pal > 0 && pr_highpalookups && prhighpalookups[pal].map &&
hicfindsubst(tilenum, 0, 0) && (hicfindsubst(tilenum, pal, 0)->palnum != pal))
if (pr_highpalookups && prhighpalookups[curbasepal][pal].map &&
hicfindsubst(tilenum, 0, 0) &&
(curbasepal || (hicfindsubst(tilenum, pal, 0)->palnum != pal)))
{
material->highpalookupmap = prhighpalookups[pal].map;
material->highpalookupmap = prhighpalookups[curbasepal][pal].map;
pal = 0;
usinghighpal = 1;
}
if ((pth = gltexcache(tilenum, pal, cmeth)))
@ -4207,7 +4227,7 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
// fullscreen tint on global palette change... this is used for nightvision and underwater tinting
// if ((hictinting[MAXPALOOKUPS-1].r + hictinting[MAXPALOOKUPS-1].g + hictinting[MAXPALOOKUPS-1].b) != 0x2FD)
if (((uint32_t)hictinting[MAXPALOOKUPS-1].r & 0xFFFFFF00) != 0xFFFFFF00)
if (!usinghighpal && ((uint32_t)hictinting[MAXPALOOKUPS-1].r & 0xFFFFFF00) != 0xFFFFFF00)
{
material->diffusemodulation[0] *= hictinting[MAXPALOOKUPS-1].r / 255.0;
material->diffusemodulation[1] *= hictinting[MAXPALOOKUPS-1].g / 255.0;

View file

@ -203,6 +203,9 @@ int32_t r_parallaxskypanning = 0;
extern int16_t editstatus;
#define MIN_CACHETIME_PRINT 5
static inline int32_t imod(int32_t a, int32_t b)
{
if (a >= 0) return(a%b);
@ -1654,7 +1657,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
static char *lastfn = NULL;
static int32_t lastsize = 0;
int32_t startticks=0, didprint=0;
int32_t startticks=0, willprint=0;
if (!hicr) return -1;
if (facen > 0)
@ -1724,15 +1727,13 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
if (lastpic && lastfn && !Bstrcmp(lastfn,fn))
{
OSD_Printf("Load tile %4d: p%d-m%d-e%d", dapic, dapalnum, dameth, effect);
didprint=1;
willprint=1;
Bmemcpy(pic, lastpic, xsiz*ysiz*sizeof(coltype));
}
else
{
if (kprender(picfil,picfillen,(intptr_t)pic,xsiz*sizeof(coltype),xsiz,ysiz,0,0)) { Bfree(picfil); Bfree(pic); return -2; }
OSD_Printf("Load tile %4d: p%d-m%d-e%d \"%s\"", dapic, dapalnum, dameth, effect, fn);
didprint=1;
willprint=2;
if (hicprecaching)
{
@ -1900,17 +1901,25 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
/// OSD_Printf("Caching \"%s\"\n", fn);
writexcache(fn, picfillen+(dapalnum<<8), dameth, effect, &cachead);
if (didprint)
if (willprint)
{
OSD_Printf("... cached... %d ms\n", getticks()-startticks);
didprint = 0;
int32_t etime = getticks()-startticks;
if (etime>=MIN_CACHETIME_PRINT)
OSD_Printf("Load tile %4d: p%d-m%d-e%d %s... cached... %d ms\n", dapic, dapalnum, dameth, effect,
willprint==2 ? fn : "", etime);
willprint = 0;
}
else
OSD_Printf("Cached \"%s\"\n", fn);
}
if (didprint)
OSD_Printf("... %d ms\n", getticks()-startticks);
if (willprint)
{
int32_t etime = getticks()-startticks;
if (etime>=MIN_CACHETIME_PRINT)
OSD_Printf("Load tile %4d: p%d-m%d-e%d %s... %d ms\n", dapic, dapalnum, dameth, effect,
willprint==2 ? fn : "", etime);
}
return 0;
}
@ -3087,7 +3096,8 @@ static void polymost_drawalls(int32_t bunch)
for (z=bunchfirst[bunch]; z>=0; z=p2[z])
{
wallnum = thewall[z]; wal = &wall[wallnum]; wal2 = &wall[wal->point2];
nextsectnum = wal->nextsector; nextsec = &sector[nextsectnum];
nextsectnum = wal->nextsector;
nextsec = nextsectnum>=0 ? &sector[nextsectnum] : NULL;
//Offset&Rotate 3D coordinates to screen 3D space
x = wal->x-globalposx; y = wal->y-globalposy;
@ -5376,6 +5386,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
if (!nofog) bglDisable(GL_FOG);
if (rendmode < 4)
mddraw(&tspr);
# ifdef POLYMER
else
{
tspriteptr[MAXSPRITESONSCREEN] = &tspr;
@ -5394,7 +5405,7 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
bglDisable(GL_BLEND);
bglDisable(GL_ALPHA_TEST);
}
# endif
if (!nofog) bglEnable(GL_FOG);
#else
mddraw(&tspr);

View file

@ -1,6 +1,7 @@
#if defined(LINKED_GTK)
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixdata.h>
#include <gdk/gdkkeysyms.h>
#else
#include "dynamicgtk.h"
#endif

View file

@ -0,0 +1,249 @@
#include "compat.h"
#include "build.h"
#include "glbuild.h"
#include "mdsprite.h"
#include <stdio.h>
#include <errno.h>
static md2head_t head;
static void quit(int32_t status)
{
exit(status);
}
static md2model_t *md2load(int *fd, const char *filename, int32_t ronly)
{
md2model_t *m;
int fil;
fil = Bopen(filename, ronly?BO_RDONLY:BO_RDWR);
if (fil<0)
{
fprintf(stderr, "Couldn't open `%s': %s\n", filename, strerror(errno));
quit(2);
}
m = (md2model_t *)Bcalloc(1,sizeof(md2model_t)); if (!m) quit(1);
m->mdnum = 2; m->scale = .01f;
Bread(fil,(char *)&head,sizeof(md2head_t));
head.id = B_LITTLE32(head.id); head.vers = B_LITTLE32(head.vers);
head.skinxsiz = B_LITTLE32(head.skinxsiz); head.skinysiz = B_LITTLE32(head.skinysiz);
head.framebytes = B_LITTLE32(head.framebytes); head.numskins = B_LITTLE32(head.numskins);
head.numverts = B_LITTLE32(head.numverts); head.numuv = B_LITTLE32(head.numuv);
head.numtris = B_LITTLE32(head.numtris); head.numglcmds = B_LITTLE32(head.numglcmds);
head.numframes = B_LITTLE32(head.numframes); head.ofsskins = B_LITTLE32(head.ofsskins);
head.ofsuv = B_LITTLE32(head.ofsuv); head.ofstris = B_LITTLE32(head.ofstris);
head.ofsframes = B_LITTLE32(head.ofsframes); head.ofsglcmds = B_LITTLE32(head.ofsglcmds);
head.ofseof = B_LITTLE32(head.ofseof);
if ((head.id != 0x32504449) || (head.vers != 8))
{
fprintf(stderr, "File `%s' is not an md2 file.\n", filename);
quit(3);
} //"IDP2"
m->numskins = head.numskins;
m->numframes = head.numframes;
m->numverts = head.numverts;
m->numglcmds = head.numglcmds;
m->framebytes = head.framebytes;
m->frames = (char *)Bmalloc(m->numframes*m->framebytes); if (!m->frames) quit(1);
m->tris = (md2tri_t *)Bmalloc(head.numtris*sizeof(md2tri_t)); if (!m->tris) quit(1);
m->uv = (md2uv_t *)Bmalloc(head.numuv*sizeof(md2uv_t)); if (!m->uv) quit(1);
Blseek(fil,head.ofsframes,SEEK_SET);
if (Bread(fil,(char *)m->frames,m->numframes*m->framebytes) != m->numframes*m->framebytes)
quit(1);
Blseek(fil,head.ofstris,SEEK_SET);
if (Bread(fil,(char *)m->tris,head.numtris*sizeof(md2tri_t)) != (int32_t)(head.numtris*sizeof(md2tri_t)))
quit(1);
Blseek(fil,head.ofsuv,SEEK_SET);
if (Bread(fil,(char *)m->uv,head.numuv*sizeof(md2uv_t)) != (int32_t)(head.numuv*sizeof(md2uv_t)))
quit(1);
#if B_BIG_ENDIAN != 0
{
char *f = (char *)m->frames;
int32_t *l,i,j;
md2frame_t *fr;
for (i = m->numframes-1; i>=0; i--)
{
fr = (md2frame_t *)f;
l = (int32_t *)&fr->mul;
for (j=5; j>=0; j--) l[j] = B_LITTLE32(l[j]);
f += m->framebytes;
}
for (i = head.numtris-1; i>=0; i--)
{
m->tris[i].v[0] = B_LITTLE16(m->tris[i].v[0]);
m->tris[i].v[1] = B_LITTLE16(m->tris[i].v[1]);
m->tris[i].v[2] = B_LITTLE16(m->tris[i].v[2]);
m->tris[i].u[0] = B_LITTLE16(m->tris[i].u[0]);
m->tris[i].u[1] = B_LITTLE16(m->tris[i].u[1]);
m->tris[i].u[2] = B_LITTLE16(m->tris[i].u[2]);
}
for (i = head.numuv-1; i>=0; i--)
{
m->uv[i].u = B_LITTLE16(m->uv[i].u);
m->uv[i].v = B_LITTLE16(m->uv[i].v);
}
}
#endif
*fd = fil;
return(m);
}
static void usage_and_quit()
{
fprintf(stderr,
"Usage:\n"
" md2tool <modelfile>.md2: display info about model\n"
" md2tool -minmax <minx>,<miny>,<minz>:<maxx>,<maxy>,<maxz> <modelfile>.md2:\n"
" modify `scale' and `translate' fields of MD2 (in-place) to produce given bounds\n"
);
quit(1);
}
int main(int argc, char **argv)
{
char *fn=NULL, *cp;
int32_t fd=-1, i, j, slen;
int32_t doinfo=1;
// md2 mul[x,y,z], add[x,y,z]
float mx,my,mz, ax,ay,az;
// desired model bounds
float dminx=0,dminy=0,dminz=0, dmaxx=1,dmaxy=1,dmaxz=1;
// md2 uint8-coordinate bounds
uint8_t maxv[3]={0,0,0};
uint8_t minv[3]={255,255,255};
md2frame_t *fr;
uint8_t *vp;
md2model_t *m;
if (argc<=1)
usage_and_quit();
for (i=1; i<argc; i++)
{
cp = argv[i];
slen = strlen(cp);
if (cp[0]=='-')
{
if (!strcmp(cp, "-minmax"))
{
doinfo=0;
if (i+1 >= argc)
usage_and_quit();
if (sscanf(argv[i+1], "%f,%f,%f:%f,%f,%f", &dminx,&dminy,&dminz, &dmaxx,&dmaxy,&dmaxz)!=6)
usage_and_quit();
i++;
}
else
{
fprintf(stderr, "unrecognized option `%s'\n", cp);
quit(2);
}
}
else
fn = cp;
}
if (!fn)
usage_and_quit();
m = md2load(&fd, fn, doinfo);
fr = (md2frame_t *)m->frames;
mx=fr->mul.x; my=fr->mul.y; mz=fr->mul.z;
ax=fr->add.x; ay=fr->add.y; az=fr->add.z;
for (i=0, vp=fr->verts->v; i<m->numverts; i++, vp+=sizeof(md2vert_t))
{
for (j=0; j<3; j++)
{
maxv[j] = max(maxv[j], vp[j]);
minv[j] = min(minv[j], vp[j]);
}
}
if (doinfo)
{
printf("------ %s ------\n", fn);
printf("numframes: %d\n", m->numframes);
printf("numverts: %d\n", m->numverts);
printf("numtris: %d\n", head.numtris);
printf("\n");
printf("ofsframes: %x\n", head.ofsframes);
printf("framebytes: %d\n", head.framebytes);
// printf("framebytes: %d, calculated=%d\n", head.framebytes, sizeof(md2frame_t)+(m->numverts-1)*sizeof(md2vert_t));
printf("\n");
printf("mul=%f %f %f\n", mx, my, mz);
printf("add=%f %f %f\n", ax, ay, az);
printf("min xyz (s+t) = %f %f %f\n", minv[0]*mx+ax, minv[1]*my+ay, minv[2]*mz+az);
printf("max xyz (s+t) = %f %f %f\n", maxv[0]*mx+ax, maxv[1]*my+ay, maxv[2]*mz+az);
printf("\n");
}
else
{
if (maxv[0]-minv[0]>0) mx = (dmaxx-dminx)/(maxv[0]-minv[0]); else mx=0;
if (maxv[1]-minv[1]>0) my = (dmaxy-dminy)/(maxv[1]-minv[1]); else my=0;
if (maxv[2]-minv[2]>0) mz = (dmaxz-dminz)/(maxv[2]-minv[2]); else mz=0;
if (mx==0||my==0||mz==0)
{
fprintf(stderr, "max[x,y,z]-min[x,y,z] must each be grater 0!\n");
quit(2);
}
ax = dmaxx-maxv[0]*mx;
ay = dmaxy-maxv[1]*my;
az = dmaxz-maxv[2]*mz;
#define ISNAN(x) ((x)!=(x))
#define ISINF(x) ((x!=0)&&(x/2==x))
if (ISNAN(mx)||ISNAN(my)||ISNAN(mz)||ISNAN(ax)||ISNAN(ay)||ISNAN(az)||
ISINF(mx)||ISINF(my)||ISINF(mz)||ISINF(ax)||ISINF(ay)||ISINF(az))
{
fprintf(stderr, "Calculation resulted in NaN or Inf.\n");
quit(2);
}
Blseek(fd,head.ofsframes,SEEK_SET);
if (Bwrite(fd, &mx, sizeof(mx))!=sizeof(mx)) { perror("write"); quit(3); }
if (Bwrite(fd, &my, sizeof(my))!=sizeof(my)) { perror("write"); quit(3); }
if (Bwrite(fd, &mz, sizeof(mz))!=sizeof(mz)) { perror("write"); quit(3); }
if (Bwrite(fd, &ax, sizeof(ax))!=sizeof(ax)) { perror("write"); quit(3); }
if (Bwrite(fd, &ay, sizeof(ay))!=sizeof(ay)) { perror("write"); quit(3); }
if (Bwrite(fd, &az, sizeof(az))!=sizeof(az)) { perror("write"); quit(3); }
Bclose(fd);
printf("wrote scale and translate of `%s'.\n", fn);
}
return 0;
}

View file

@ -372,6 +372,10 @@ defstate fiddlewithlights
ifeithershift inv j
set k 0
ifhitkey KEY_B { add .xvel j, set k 1 }
ifhitkey KEY_N { add .yvel j, set k 1 }
ifhitkey KEY_M { add .zvel j, set k 1 }
ifhitkey KEY_KP1 { add .xvel j, set k 1 }
ifhitkey KEY_KP2 { add .yvel j, set k 1 }
ifhitkey KEY_KP3 { add .zvel j, set k 1 }

View file

@ -42,7 +42,9 @@ defstate arraytest
ends
defstate itertest
// iteration and break test
var gi gj gk
// iteration and break test
for i range 10
{
addlogvar i
@ -82,70 +84,70 @@ define MIN_CONSTANT -2147483648
defstate consttest
quote " --- Constants test ---", quote " "
quote "Shoud be 0:"
quote "Should be 0:"
set i 0, set j TEST_ZERO
qsprintf TQUOTE "%d %d %d %d" 0 TEST_ZERO i j
quote TQUOTE, quote " "
quote "Shoud be 1:"
quote "Should be 1:"
set i 1, set j TEST_PLUS_ONE
qsprintf TQUOTE "%d %d %d %d" 1 TEST_PLUS_ONE i j
quote TQUOTE, quote " "
quote "Shoud be -1:"
quote "Should be -1:"
set i -1, set j TEST_MINUS_ONE
qsprintf TQUOTE "%d %d %d %d" -1 TEST_MINUS_ONE i j
quote TQUOTE, quote " "
quote "Shoud be 32767:"
quote "Should be 32767:"
set i 32767, set j MOST_POSITIVE_DIRECT
qsprintf TQUOTE "%d %d %d %d" 32767 MOST_POSITIVE_DIRECT i j
quote TQUOTE, quote " "
quote "Shoud be -32768:"
quote "Should be -32768:"
set i -32768, set j MOST_NEGATIVE_DIRECT
qsprintf TQUOTE "%d %d %d %d" -32768 MOST_NEGATIVE_DIRECT i j
quote TQUOTE, quote " "
quote "Shoud be 32768:"
quote "Should be 32768:"
set i 32768, set j LEAST_POSITIVE_INDIRECT
qsprintf TQUOTE "%d %d %d %d" 32768 LEAST_POSITIVE_INDIRECT i j
quote TQUOTE, quote " "
quote "Shoud be -32769:"
quote "Should be -32769:"
set i -32769, set j LEAST_NEGATIVE_INDIRECT
qsprintf TQUOTE "%d %d %d %d" -32769 LEAST_NEGATIVE_INDIRECT i j
quote TQUOTE, quote " "
quote "Hex tests:"
quote "Shoud be 32767:"
quote "Should be 32767:"
set i 0x7fff, set j HEX_MOST_POSITIVE_DIRECT
qsprintf TQUOTE "%d %d %d %d" 0x7fff HEX_MOST_POSITIVE_DIRECT i j
quote TQUOTE, quote " "
quote "Shoud be -32768:"
quote "Should be -32768:"
set i 0xffff8000, set j HEX_MOST_NEGATIVE_DIRECT
qsprintf TQUOTE "%d %d %d %d" 0xffff8000 HEX_MOST_NEGATIVE_DIRECT i j
quote TQUOTE, quote " "
quote "Shoud be 32768:"
quote "Should be 32768:"
set i 0x8000, set j HEX_LEAST_POSITIVE_INDIRECT
qsprintf TQUOTE "%d %d %d %d" 0x8000 HEX_LEAST_POSITIVE_INDIRECT i j
quote TQUOTE, quote " "
quote "Shoud be -32769:"
quote "Should be -32769:"
set i 0xffff7fff, set j HEX_LEAST_NEGATIVE_INDIRECT
qsprintf TQUOTE "%d %d %d %d" 0xffff7fff HEX_LEAST_NEGATIVE_INDIRECT i j
quote TQUOTE, quote " "
quote "min/max tests:"
quote "Shoud be 2147483647:"
quote "Should be 2147483647:"
set i 2147483647, set j MAX_CONSTANT
qsprintf TQUOTE "%d %d %d %d" 2147483647 MAX_CONSTANT i j
quote TQUOTE, quote " "
quote "Shoud be -2147483648:"
quote "Should be -2147483648:"
set i -2147483648, set j MIN_CONSTANT
qsprintf TQUOTE "%d %d %d %d" -2147483648 MIN_CONSTANT i j
quote TQUOTE, quote " "

View file

@ -3,8 +3,6 @@
#include "names.h"
// tilegroup "All named" with the hotkey "Y" is constructed automatically
tilegroup "Actors"
{
hotkey "A"

File diff suppressed because it is too large Load diff

View file

@ -102,7 +102,7 @@ char g_modDir[BMAX_PATH] = "/";
uint8_t water_pal[768],slime_pal[768],title_pal[768],dre_alms[768],ending_pal[768],*anim_pal;
uint8_t *basepaltable[BASEPALCOUNT] = { palette, water_pal, slime_pal, title_pal, dre_alms, ending_pal, NULL };
uint8_t *basepaltable[BASEPALCOUNT] = { palette, water_pal, slime_pal, dre_alms, title_pal, ending_pal, NULL };
static int32_t g_skipDefaultCons = 0;
@ -296,7 +296,7 @@ void P_SetGamePalette(DukePlayer_t *player, uint8_t palid, int32_t set)
player->palette = palid;
setbrightness(ud.brightness>>2, basepaltable[palid], set);
setbrightness(ud.brightness>>2, palid, set);
}
int32_t G_PrintGameText(int32_t f, int32_t tile, int32_t x, int32_t y, const char *t,
@ -9048,6 +9048,8 @@ static void G_Startup(void)
fprintf(stderr, "G_Startup: There was a problem initializing the Build engine: %s\n", engineerrstr);
exit(6);
}
setbasepaltable(basepaltable, BASEPALCOUNT);
G_InitDynamicTiles();
@ -9910,7 +9912,7 @@ CLEAN_DIRECTORY:
ud.config.ScreenBPP = bpp[i];
}
setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0);
setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
S_MusicStartup();
S_SoundStartup();

View file

@ -227,6 +227,7 @@ 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;
@ -237,8 +238,8 @@ typedef enum basepal_ {
BASEPAL = 0,
WATERPAL,
SLIMEPAL,
TITLEPAL,
DREALMSPAL,
TITLEPAL,
ENDINGPAL,
ANIMPAL
} basepal_t;

View file

@ -1110,7 +1110,7 @@ static int32_t C_SetScriptSize(int32_t size)
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 %d (0x%x)\n",i,i);
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");
@ -1145,7 +1145,7 @@ static int32_t C_SetScriptSize(int32_t size)
//initprintf("offset: %d\n",(unsigned)(g_scriptPtr-script));
g_scriptSize = size;
initprintf("Resizing code buffer to %d*%d bytes\n",g_scriptSize, sizeof(intptr_t));
initprintf("Resizing code buffer to %d*%d bytes\n",g_scriptSize, (int32_t)sizeof(intptr_t));
newscript = (intptr_t *)Brealloc(script, g_scriptSize * sizeof(intptr_t));
@ -3108,7 +3108,7 @@ static int32_t C_ParseCommand(void)
i = *(g_scriptPtr-1);
*(g_scriptPtr-1) ^= 48;
C_ReportError(-1);
initprintf("%s:%d: warning: tried to set cstat %d, using %d instead.\n",g_szScriptFileName,g_lineNumber,i,*(g_scriptPtr-1));
initprintf("%s:%d: warning: tried to set cstat %d, using %d instead.\n",g_szScriptFileName,g_lineNumber,i,(int32_t)(*(g_scriptPtr-1)));
g_numCompilerWarnings++;
}
}
@ -5214,7 +5214,7 @@ repeatcase:
if (i >= (signed)sizeof(EpisodeNames[j])-1)
{
initprintf("%s:%d: warning: truncating volume name to %d characters.\n",
g_szScriptFileName,g_lineNumber,sizeof(EpisodeNames[j])-1);
g_szScriptFileName,g_lineNumber,(int32_t)sizeof(EpisodeNames[j])-1);
g_numCompilerWarnings++;
C_NextLine();
break;
@ -5301,7 +5301,7 @@ repeatcase:
if (i >= (signed)sizeof(SkillNames[j])-1)
{
initprintf("%s:%d: warning: truncating skill name to %d characters.\n",
g_szScriptFileName,g_lineNumber,sizeof(SkillNames[j])-1);
g_szScriptFileName,g_lineNumber,(int32_t)sizeof(SkillNames[j])-1);
g_numCompilerWarnings++;
C_NextLine();
break;
@ -5326,7 +5326,7 @@ repeatcase:
if (i >= (signed)sizeof(gamename)-1)
{
initprintf("%s:%d: warning: truncating game name to %d characters.\n",
g_szScriptFileName,g_lineNumber,sizeof(gamename)-1);
g_szScriptFileName,g_lineNumber,(int32_t)sizeof(gamename)-1);
g_numCompilerWarnings++;
C_NextLine();
break;
@ -5457,7 +5457,7 @@ repeatcase:
if (i >= (signed)sizeof(GametypeNames[j])-1)
{
initprintf("%s:%d: warning: truncating gametype name to %d characters.\n",
g_szScriptFileName,g_lineNumber,sizeof(GametypeNames[j])-1);
g_szScriptFileName,g_lineNumber,(int32_t)sizeof(GametypeNames[j])-1);
g_numCompilerWarnings++;
C_NextLine();
break;
@ -6327,11 +6327,11 @@ void C_Compile(const char *filenam)
C_SetScriptSize(g_scriptPtr-script+8);
initprintf("Script compiled in %dms, %ld*%db, version %s\n", getticks() - startcompiletime,
(unsigned long)(g_scriptPtr-script), sizeof(intptr_t), (g_scriptVersion == 14?"1.4+":"1.3D"));
(unsigned long)(g_scriptPtr-script), (int32_t)sizeof(intptr_t), (g_scriptVersion == 14?"1.4+":"1.3D"));
initprintf("%d/%d labels, %d/%d variables\n", g_numLabels,
min((MAXSECTORS * sizeof(sectortype)/sizeof(int32_t)),
MAXSPRITES * sizeof(spritetype)/(1<<6)),
(int32_t)min((MAXSECTORS * sizeof(sectortype)/sizeof(int32_t)),
MAXSPRITES * sizeof(spritetype)/(1<<6)),
g_gameVarCount, MAXGAMEVARS);
for (i=MAXQUOTES-1; i>=0; i--)

View file

@ -67,9 +67,9 @@ void VM_ScriptInfo(void)
for (p=insptr-20; p<insptr+20; p++)
{
if (*p>>12&&(*p&0xFFF)<CON_END)
initprintf("\n%5d: %5d %s ",p-script,*p>>12,keyw[*p&0xFFF]);
initprintf("\n%5d: %5d %s ",(int32_t)(p-script),(int32_t)(*p>>12),keyw[*p&0xFFF]);
else
initprintf(" %d",*p);
initprintf(" %d",(int32_t)*p);
}
initprintf("\n");
@ -1012,7 +1012,7 @@ skip_check:
insptr++;
if ((*insptr<0 || *insptr>=MAXSOUNDS))
{
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],*insptr++);
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr++);
continue;
}
if (!S_CheckSoundPlaying(vm.g_i,*insptr++))
@ -1039,7 +1039,7 @@ skip_check:
insptr++;
if ((*insptr<0 || *insptr>=MAXSOUNDS))
{
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],*insptr);
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr);
insptr++;
continue;
}
@ -1051,7 +1051,7 @@ skip_check:
insptr++;
if ((*insptr<0 || *insptr>=MAXSOUNDS))
{
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],*insptr);
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr);
insptr++;
continue;
}
@ -1081,7 +1081,7 @@ skip_check:
insptr++;
if ((*insptr<0 || *insptr>=MAXSOUNDS))
{
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],*insptr);
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr);
insptr++;
continue;
}
@ -1094,7 +1094,7 @@ skip_check:
insptr++;
if ((*insptr<0 || *insptr>=MAXSOUNDS))
{
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],*insptr);
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr);
insptr++;
continue;
}
@ -1208,7 +1208,7 @@ skip_check:
insptr++;
if ((*insptr<0 || *insptr>=MAX_WEAPONS))
{
OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",g_errorLineNum,keyw[g_tw],*insptr);
OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr);
insptr += 2; break;
}
if (g_player[vm.g_p].ps->ammo_amount[*insptr] >= g_player[vm.g_p].ps->max_ammo_amount[*insptr])
@ -1266,7 +1266,7 @@ skip_check:
insptr++;
if ((*insptr<0 ||*insptr>=MAX_WEAPONS))
{
OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",g_errorLineNum,keyw[g_tw],*insptr);
OSD_Printf(CON_ERROR "Invalid weapon ID %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr);
insptr += 2;
continue;
}
@ -1291,7 +1291,7 @@ skip_check:
case CON_DEBUG:
insptr++;
initprintf("%d\n",*insptr++);
initprintf("%"PRIdPTR"\n",*insptr++);
continue;
case CON_ENDOFGAME:
@ -3019,7 +3019,7 @@ nullquote:
g_player[vm.g_p].ps->inv_amount[GET_BOOTS] = *insptr;
break;
default:
OSD_Printf(CON_ERROR "Invalid inventory ID %d\n",g_errorLineNum,keyw[g_tw],*(insptr-1));
OSD_Printf(CON_ERROR "Invalid inventory ID %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*(insptr-1));
break;
}
insptr++;
@ -4575,7 +4575,7 @@ nullquote:
if (g_player[vm.g_p].ps->inv_amount[GET_BOOTS] != *insptr) j = 1;
break;
default:
OSD_Printf(CON_ERROR "invalid inventory ID: %d\n",g_errorLineNum,keyw[g_tw],*(insptr-1));
OSD_Printf(CON_ERROR "invalid inventory ID: %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*(insptr-1));
}
VM_DoConditional(j);
@ -4633,14 +4633,14 @@ nullquote:
if ((ScriptQuotes[*insptr] == NULL))
{
OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],*insptr);
OSD_Printf(CON_ERROR "null quote %d\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr);
insptr++;
continue;
}
if ((vm.g_p < 0 || vm.g_p >= MAXPLAYERS))
{
OSD_Printf(CON_ERROR "bad player for quote %d: (%d)\n",g_errorLineNum,keyw[g_tw],*insptr,vm.g_p);
OSD_Printf(CON_ERROR "bad player for quote %d: (%d)\n",g_errorLineNum,keyw[g_tw],(int32_t)*insptr,vm.g_p);
insptr++;
continue;
}

View file

@ -356,7 +356,7 @@ void Gv_DumpValues(void)
else if (aGameVars[i].dwFlags & (GAMEVAR_PERACTOR))
OSD_Printf(" GAMEVAR_PERACTOR");
else
OSD_Printf(" %d",aGameVars[i].dwFlags/* & (GAMEVAR_USER_MASK)*/);
OSD_Printf(" %"PRIdPTR,aGameVars[i].dwFlags/* & (GAMEVAR_USER_MASK)*/);
OSD_Printf(" // ");
if (aGameVars[i].dwFlags & (GAMEVAR_SYSTEM))

View file

@ -18,6 +18,14 @@ CFLAGS=$(BASECFLAGS) $(F_NO_STACK_PROTECTOR)
OURCFLAGS=$(CFLAGS)
CPPFLAGS=-I$(INC) -I$(SRC) -DHAVE_VORBIS
ifeq ($(PLATFORM),DARWIN)
ifeq (1,$(SDL_FRAMEWORK))
APPLE_INCLUDE_DIR:=../../Apple/include
OURCFLAGS += -DSDL_FRAMEWORK -I$(APPLE_INCLUDE_DIR) -I/Library/Frameworks/SDL.framework/Headers \
-I/Library/Frameworks/SDL_mixer.framework/Headers
endif
endif
OBJECTS=$(OBJ)/drivers.o \
$(OBJ)/fx_man.o \
@ -48,7 +56,7 @@ $(OBJNAME): $(OBJECTS)
$(OBJECTS): $(OBJ)/%.o: $(SRC)/%.c
-mkdir -p $(OBJ)
$(COMPILE_STATUS)
if $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
if $(CC) $(CPPFLAGS) $(OURCFLAGS) -c $< -o $@; then $(COMPILE_OK); else $(COMPILE_FAILED); fi
ifeq ($(PRETTY_OUTPUT),1)
.SILENT:

View file

@ -450,8 +450,8 @@ const memberlabel_t SectorLabels[]=
const memberlabel_t WallLabels[]=
{
{ "x", WALL_X, 0, -524288, 524288 },
{ "y", WALL_Y, 0, -524288, 524288 },
{ "x", WALL_X, 0, -BXY_MAX, BXY_MAX },
{ "y", WALL_Y, 0, -BXY_MAX, BXY_MAX },
{ "point2", WALL_POINT2, 1, 0, 0 },
{ "nextwall", WALL_NEXTWALL, 1, 0, 0 },
{ "nextsector", WALL_NEXTSECTOR, 1, 0, 0 },
@ -472,8 +472,8 @@ const memberlabel_t WallLabels[]=
const memberlabel_t SpriteLabels[]=
{
{ "x", SPRITE_X, 0, -524288, 524288 },
{ "y", SPRITE_Y, 0, -524288, 524288 },
{ "x", SPRITE_X, 0, -BXY_MAX, BXY_MAX },
{ "y", SPRITE_Y, 0, -BXY_MAX, BXY_MAX },
{ "z", SPRITE_Z, 0, 0, 0 },
{ "cstat", SPRITE_CSTAT, 0, 0, 0 },
{ "picnum", SPRITE_PICNUM, 0, 0, MAXTILES-1 },
@ -585,7 +585,7 @@ static int32_t C_SetScriptSize(int32_t size)
//initprintf("offset: %d\n",(unsigned)(g_scriptPtr-script));
g_scriptSize = size;
initprintf("Resizing code buffer to %d*%d bytes\n", g_scriptSize, sizeof(instype));
initprintf("Resizing code buffer to %d*%d bytes\n", g_scriptSize, (int32_t)sizeof(instype));
newscript = (instype *)Brealloc(script, g_scriptSize * sizeof(instype));
@ -909,6 +909,26 @@ static int32_t GetGamearrayID(const char *szGameLabel, int32_t searchlocals)
#define GV_WRITABLE GAMEVAR_READONLY
#define GV_SIMPLE GAMEVAR_SPECIAL
static int32_t parse_integer_literal(int32_t *num)
{
if (tolower(textptr[1])=='x')
sscanf(textptr+2, "%" SCNx32, num);
else
{
long lnum;
errno = 0;
lnum = strtol(textptr, NULL, 10);
if (errno || (sizeof(long)>4 && (lnum<INT_MIN || lnum>INT_MAX)))
{
C_CUSTOMERROR("integer literal exceeds bitwidth.");
return 1;
}
*num = (int32_t)lnum;
}
return 0;
}
static void C_GetNextVarType(int32_t type)
{
int32_t i, id=0, flags=0, num, indirect=0; //, thenum;
@ -940,13 +960,10 @@ static void C_GetNextVarType(int32_t type)
// if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug)
// initprintf("%s:%d: debug: accepted constant %d in place of gamevar.\n",g_szScriptFileName,g_lineNumber,atol(textptr));
if (tolower(textptr[1])=='x')
sscanf(textptr+2, "%" SCNx32, &num);
else
num = atoi(textptr);
parse_integer_literal(&num);
//thenum=num;
if (type==GV_SIMPLE && (num<0 || num>=65536))
C_CUSTOMERROR("array index %d out of bounds. (max: 65535)", num);
C_CUSTOMERROR("array index %d out of bounds. (max: 65535)", num);
if (g_numCompilerErrors==0 && type!=GV_SIMPLE && num != (int16_t)num)
{
@ -1442,10 +1459,7 @@ static int32_t C_GetNextValue(int32_t type)
// if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1)
// initprintf("%s:%d: debug: accepted constant %d.\n",g_szScriptFileName,g_lineNumber,atol(textptr));
if (tolower(textptr[1])=='x')
sscanf(textptr+2,"%" SCNx32 "",g_scriptPtr);
else
*g_scriptPtr = atol(textptr);
parse_integer_literal(g_scriptPtr);
g_scriptPtr++;
@ -3188,7 +3202,7 @@ repeatcase:
if (!ScriptQuotes[k])
{
Bsprintf(tempbuf,"Failed allocating %" PRIdPTR " byte quote text buffer.", MAXQUOTELEN);
Bsprintf(tempbuf,"Failed allocating %d byte quote text buffer.", MAXQUOTELEN);
g_numCompilerErrors++;
return 1;
}
@ -3205,7 +3219,7 @@ repeatcase:
ScriptQuoteRedefinitions[g_numQuoteRedefinitions] = Bcalloc(MAXQUOTELEN, sizeof(uint8_t));
if (!ScriptQuoteRedefinitions[g_numQuoteRedefinitions])
{
Bsprintf(tempbuf,"Failed allocating %" PRIdPTR " byte quote text buffer.", MAXQUOTELEN);
Bsprintf(tempbuf,"Failed allocating %d byte quote text buffer.", MAXQUOTELEN);
g_numCompilerErrors++;
return 1;
}
@ -3591,7 +3605,7 @@ void C_CompilationInfo(void)
int32_t j, k=0;
initprintf(" \n");
initprintf("Compiled code info: (size=%ld*%d bytes)\n",
(unsigned long)(g_scriptPtr-script), sizeof(instype));
(unsigned long)(g_scriptPtr-script), (int32_t)sizeof(instype));
initprintf(" %d/%d user labels, %d/65536 indirect constants,\n",
g_numLabels-g_numDefaultLabels, 65536-g_numDefaultLabels,
g_numSavedConstants);

View file

@ -70,7 +70,7 @@ extern int32_t g_stateCount;
typedef struct
{
char *name;
const char *name;
int16_t lId;
int16_t flags; // 1: read-only
int32_t min, max;
@ -82,7 +82,8 @@ extern const memberlabel_t SpriteLabels[];
typedef struct {
char* token; int32_t val;
const char* token;
int32_t val;
} tokenmap_t;
extern const tokenmap_t iter_tokens[];

View file

@ -120,7 +120,7 @@ void VM_ScriptInfo(void)
if (p==insptr) initprintf("<<");
if (*p>>12 && (*p&0xFFF)<CON_END)
initprintf("\n%5d: L%5d: %s ",p-script,*p>>12,keyw[*p&0xFFF]);
initprintf("\n%5d: L%5d: %s ",(int32_t)(p-script),(int32_t)(*p>>12),keyw[*p&0xFFF]);
else initprintf(" %d",*p);
if (p==insptr) initprintf(">>");
@ -440,9 +440,11 @@ skip_check:
//AddLog("Done Executing Case");
bMatched=1;
}
if (right-left < 0)
break;
}
if (!bMatched)
{
if (*lpDefault >= 0)
@ -2868,7 +2870,7 @@ dodefault:
{
screencoords(&x1,&y1, x1-pos.x,y1-pos.y, zoom);
if (m32_sideview)
y1 += getscreenvdisp(z1, zoom);
y1 += getscreenvdisp(z1-pos.z, zoom);
r = mulscale14(r,zoom);
eccen = scalescreeny(eccen);
xofs = halfxdim16;

View file

@ -630,6 +630,23 @@ static void Gv_AddSystemVars(void)
Gv_NewVar("pr_overridespecular",(intptr_t)&pr_overridespecular, GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
Gv_NewVar("pr_specularpower",(intptr_t)&pr_specularpower, GAMEVAR_FLOATPTR | GAMEVAR_SYSTEM);
Gv_NewVar("pr_specularfactor",(intptr_t)&pr_specularfactor, GAMEVAR_FLOATPTR | GAMEVAR_SYSTEM);
#else
{
// dummy Polymer variables for non-Polymer builds
static int32_t pr_overrideparallax = 0;
static float pr_parallaxscale = 0.1f;
static float pr_parallaxbias = 0.0f;
static int32_t pr_overridespecular = 0;
static float pr_specularpower = 15.0f;
static float pr_specularfactor = 1.0f;
Gv_NewVar("pr_overrideparallax",(intptr_t)&pr_overrideparallax, GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
Gv_NewVar("pr_parallaxscale",(intptr_t)&pr_parallaxscale, GAMEVAR_FLOATPTR | GAMEVAR_SYSTEM);
Gv_NewVar("pr_parallaxbias",(intptr_t)&pr_parallaxbias, GAMEVAR_FLOATPTR | GAMEVAR_SYSTEM);
Gv_NewVar("pr_overridespecular",(intptr_t)&pr_overridespecular, GAMEVAR_INTPTR | GAMEVAR_SYSTEM);
Gv_NewVar("pr_specularpower",(intptr_t)&pr_specularpower, GAMEVAR_FLOATPTR | GAMEVAR_SYSTEM);
Gv_NewVar("pr_specularfactor",(intptr_t)&pr_specularfactor, GAMEVAR_FLOATPTR | GAMEVAR_SYSTEM);
}
#endif
g_systemVarCount = g_gameVarCount;

View file

@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// #define VULGARITY
char *defsfilename = "duke3d.def";
const char *defsfilename = "duke3d.def";
extern char keystatus[];
extern int16_t defaultspritecstat;
@ -76,7 +76,7 @@ static char autospritehelp=0,autosecthelp=0;
static int32_t lastmessagetime=-1;
static char tempbuf[1024];
static int32_t numsprite[MAXSPRITES], multisprite[MAXSPRITES];
static int32_t numsprite[MAXTILES], multisprite[MAXTILES];
static char lo[64];
static char levelname[BMAX_PATH];
static int16_t curwall=0, curwallnum=0;
@ -100,7 +100,7 @@ extern int32_t vel, svel, hvel, angvel;
static void SearchSectors(int32_t dir);
static inline void SpriteName(int16_t spritenum, char *lo2);
static void PrintStatus(const char *string,int32_t num,char x,char y,char color);
//static void PrintStatus(const char *string,int32_t num,char x,char y,char color);
void SetBOSS1Palette();
void SetSLIMEPalette();
void SetWATERPalette();
@ -113,9 +113,14 @@ static void EditWallData(int16_t wallnum);
static void EditSectorData(int16_t sectnum);
static void FuncMenu(void);
#define BASEPALCOUNT 7
static uint8_t GAMEpalette[768], WATERpalette[768], SLIMEpalette[768], TITLEpalette[768];
static uint8_t REALMSpalette[768], BOSS1palette[768];
uint8_t *basepaltable[BASEPALCOUNT] = { palette, WATERpalette, SLIMEpalette, TITLEpalette, REALMSpalette, BOSS1palette, GAMEpalette };
static char num_tables;
static int32_t updownunits=1024;
@ -211,8 +216,8 @@ extern int16_t localartlookup[MAXTILES], localartlookupnum;
extern int32_t lockclock;
extern void clearkeys(void);
static int32_t gs_sprite[3][7];
static char gs_spritewhat[3][7];
static int32_t gs_spriteTagValue[3][7];
static char gs_spriteTagInterested[3][7];
static int16_t gs_cursprite=-1;
int32_t g_musicSize=0;

View file

@ -2613,7 +2613,7 @@ cheat_for_port_credits:
vid_gamma = (double)b/40960.f;
ud.brightness = (int32_t)(min(max((double)((vid_gamma-1.0)*10.0),0),15));
ud.brightness <<= 2;
setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0);
setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
}
b = (int32_t)(vid_contrast*40960.f);
@ -2622,7 +2622,7 @@ cheat_for_port_credits:
if (b != (vid_contrast*40960.f))
{
vid_contrast = (double)b/40960.f;
setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0);
setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
}
b = (int32_t)(vid_brightness*40960.f);
@ -2631,7 +2631,7 @@ cheat_for_port_credits:
if (b != (vid_brightness*40960.f))
{
vid_brightness = (double)b/40960.f;
setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0);
setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
}
if (x == 3)
@ -2640,7 +2640,7 @@ cheat_for_port_credits:
vid_contrast = DEFAULT_CONTRAST;
vid_brightness = DEFAULT_BRIGHTNESS;
ud.brightness = 0;
setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0);
setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
}
}

View file

@ -731,7 +731,7 @@ void onvideomodechange(int32_t newmode)
}
#endif
setbrightness(ud.brightness>>2, basepaltable[palid], 0);
setbrightness(ud.brightness>>2, palid, 0);
g_restorePalette = 1;
g_crosshairSum = 0;
}
@ -1210,7 +1210,7 @@ static int32_t osdcmd_kick(const osdfuncparm_t *parm)
if (currentPeer -> state != ENET_PEER_STATE_CONNECTED)
continue;
sscanf(parm->parms[0],"%" PRIxPTR "", &hexaddr);
sscanf(parm->parms[0],"%" SCNx32 "", &hexaddr);
if (currentPeer->address.host == hexaddr)
{
@ -1246,7 +1246,7 @@ static int32_t osdcmd_kickban(const osdfuncparm_t *parm)
if (currentPeer -> state != ENET_PEER_STATE_CONNECTED)
continue;
sscanf(parm->parms[0],"%" PRIxPTR "", &hexaddr);
sscanf(parm->parms[0],"%" SCNx32 "", &hexaddr);
// TODO: implement banning logic
@ -1304,19 +1304,19 @@ static int32_t osdcmd_cvar_set_game(const osdfuncparm_t *parm)
{
ud.brightness = GAMMA_CALC;
ud.brightness <<= 2;
setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0);
setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
return r;
}
else if (!Bstrcasecmp(parm->name, "vid_brightness"))
{
setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0);
setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
return r;
}
else if (!Bstrcasecmp(parm->name, "vid_contrast"))
{
setbrightness(ud.brightness>>2,basepaltable[g_player[myconnectindex].ps->palette],0);
setbrightness(ud.brightness>>2,g_player[myconnectindex].ps->palette,0);
return r;
}

View file

@ -1085,6 +1085,9 @@ static inline void prelevel(char g)
{
if (PN == SECTOREFFECTOR && SLT == 14)
A_Spawn(-1,i);
if (sprite[i].cstat&2048)
actor[i].flags |= SPRITE_NOSHADE;
}
lotaglist = 0;

View file

@ -937,7 +937,7 @@ static uint8_t savegame_comprthres;
// 64
#define DS_LOADFN 128 // .ptr is function that is run when loading
#define DS_SAVEFN 256 // .ptr is function that is run when saving
#define DS_NOCHK 1024 // don't check for diffs (and don't write out in dump) since assumend constant throughout demo
#define DS_NOCHK 1024 // don't check for diffs (and don't write out in dump) since assumed constant throughout demo
#define DS_END (0x70000000)
static int32_t ds_getcnt(const dataspec_t *sp)
@ -1721,7 +1721,7 @@ int32_t sv_loadsnapshot(int32_t fil, int32_t *ret_hasdiffs, int32_t *ret_demotic
if (p != svsnapshot+svsnapsiz)
{
OSD_Printf("sv_loadsnapshot: internal error: p-(snapshot end)=%d!\n",
p-(svsnapshot+svsnapsiz));
(int32_t)(p-(svsnapshot+svsnapsiz)));
sv_freemem();
return 6;
}
@ -2042,7 +2042,7 @@ static void sv_restload()
#define SAVEWR(ptr, sz, cnt) do { if (fil) dfwrite(ptr,sz,cnt,fil); } while (0)
#define SAVEWRU(ptr, sz, cnt) do { if (fil) fwrite(ptr,sz,cnt,fil); } while (0)
#define PRINTSIZE(name) OSD_Printf(#name ": %d\n", mem-tmem), tmem=mem
#define PRINTSIZE(name) OSD_Printf(#name ": %d\n", (int32_t)(mem-tmem)), tmem=mem
static uint8_t *dosaveplayer2(int32_t spot, FILE *fil, uint8_t *mem)
{

View file

@ -226,7 +226,7 @@ fallback:
}
{
static char *s[] = { "/etc/timidity.cfg", "/etc/timidity/timidity.cfg", "/etc/timidity/freepats.cfg" };
static const char *s[] = { "/etc/timidity.cfg", "/etc/timidity/timidity.cfg", "/etc/timidity/freepats.cfg" };
FILE *fp;
int32_t i;

View file

@ -61,8 +61,8 @@ void S_SoundStartup(void)
if (FX_Init(fxdevicetype, ud.config.NumVoices, ud.config.NumChannels, ud.config.NumBits, ud.config.MixRate, initdata) != FX_Ok)
{
sprintf(tempbuf, "Sound startup error: %s", FX_ErrorString(FX_Error));
G_GameExit(tempbuf);
initprintf("%s\n", FX_ErrorString(FX_Error));
return;
}
for (i=g_maxSoundPos; i >= 0 ; i--)

View file

@ -518,7 +518,11 @@ static GtkWidget *create_window(void)
// 3D video mode LabelText
stwidgets.vmode3dlabel = gtk_label_new_with_mnemonic("_Video mode:");
gtk_misc_set_alignment(GTK_MISC(stwidgets.vmode3dlabel), 0.3, 0);
#ifdef POLYMER
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dlabel, 0,1, 0,1, GTK_FILL, 0, 4, 0);
#else
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dlabel, 0,1, 0,1, GTK_FILL, 0, 4, 7);
#endif
// 3D video mode combo
{
@ -532,11 +536,21 @@ static GtkWidget *create_window(void)
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(stwidgets.vmode3dcombo), cell, "text", 0, NULL);
}
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dcombo, 1,2, 0,1, GTK_EXPAND | GTK_FILL, 0, 4, 0);
#ifdef POLYMER
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dcombo, 1,2, 0,1, GTK_EXPAND | GTK_FILL, 0, 4, 0);
#else
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.vmode3dcombo, 1,2, 0,1, GTK_EXPAND | GTK_FILL, 0, 4, 7);
#endif
// Fullscreen checkbox
stwidgets.displayvlayout = gtk_vbox_new(TRUE, 0);
#ifdef POLYMER
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.displayvlayout, 2,3, 0,1, GTK_FILL, 0, 4, 0);
#else
gtk_table_attach(GTK_TABLE(stwidgets.configtlayout), stwidgets.displayvlayout, 2,3, 0,1, GTK_FILL, 0, 4, 7);
#endif
stwidgets.fullscreencheck = gtk_check_button_new_with_mnemonic("_Fullscreen");
gtk_box_pack_start(GTK_BOX(stwidgets.displayvlayout), stwidgets.fullscreencheck, FALSE, FALSE, 0);