From cd085abf8d40bab6e2f255e015e5669b228c75df Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 2 Feb 2008 16:38:30 +0000 Subject: [PATCH] Patch from hunter_rus git-svn-id: https://svn.eduke32.com/eduke32@606 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/build/include/build.h | 2 +- polymer/build/src/build.c | 44 +++++++++++++++++++++++++++++-- polymer/build/src/engine.c | 7 ++++- polymer/build/src/mdsprite.c | 37 +++++++++++--------------- polymer/build/src/polymost.c | 3 ++- polymer/eduke32/source/config.c | 1 + polymer/eduke32/source/game.c | 2 +- polymer/eduke32/source/savegame.c | 13 +++++++++ 8 files changed, 82 insertions(+), 27 deletions(-) diff --git a/polymer/build/include/build.h b/polymer/build/include/build.h index 43badba53..dd28d3101 100644 --- a/polymer/build/include/build.h +++ b/polymer/build/include/build.h @@ -158,7 +158,6 @@ typedef struct BPACK typedef struct BPACK { unsigned int mdanimtims; - int oldmdtims; short mdanimcur; short angoff; short pitch, roll; @@ -523,6 +522,7 @@ extern int r_vertexarrays; extern int r_vbos; extern int r_vbocount; extern int r_animsmoothing; +extern int mdtims, omdtims; #endif void hicinit(void); diff --git a/polymer/build/src/build.c b/polymer/build/src/build.c index b90db4564..66b8b9f2d 100644 --- a/polymer/build/src/build.c +++ b/polymer/build/src/build.c @@ -194,6 +194,7 @@ int gettile(int tilenum); int menuselect(void); int getfilenames(char *path, char *kind); void clearfilenames(void); +void loadmhk(); void clearkeys(void) { memset(keystatus,0,sizeof(keystatus)); } @@ -355,6 +356,7 @@ int app_main(int argc, const char **argv) ExtPreLoadMap(); i = loadboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&posx,&posy,&posz,&ang,&cursectnum); + loadmhk(); if (i == -2) i = loadoldboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&posx,&posy,&posz,&ang,&cursectnum); if (i < 0) { @@ -511,6 +513,25 @@ void showmouse(void) } } +int mhk=0; +void loadmhk() +{ + char *p;char levname[BMAX_PATH]; + + if(!mhk)return; + strcpy(levname, boardfilename); + p = Bstrrchr(levname,'.'); + if (!p) strcat(levname,".mhk"); + else + { + p[1]='m'; + p[2]='h'; + p[3]='k'; + p[4]=0; + } + if (!loadmaphack(levname))initprintf("Loaded map hack file '%s'\n",levname);else mhk=2; +} + void editinput(void) { char smooshyalign, repeatpanalign, *ptr, buffer[80]; @@ -583,8 +604,26 @@ void editinput(void) if (keystatus[0x3c] > 0) posx++; if (keystatus[0x3d] > 0) posy--; if (keystatus[0x3e] > 0) posy++; - if (keystatus[0x43] > 0) ang--; - if (keystatus[0x44] > 0) ang++; +// if (keystatus[0x43] > 0) ang--; +// if (keystatus[0x44] > 0) ang++; + + if (keystatus[0x43] > 0) + { + mhk=1; + loadmhk(); + keystatus[0x43] = 0; + } + if (keystatus[0x44] > 0) + { + memset(spriteext, 0, sizeof(spriteexttype) * MAXSPRITES); + memset(spritesmooth, 0, sizeof(spritesmooth)); + mhk=0; + initprintf("Maphacks dissabled\n"); + keystatus[0x44] = 0; + } + begindrawing(); //{{{ + if(mhk)printext256(0,16,whitecol,0,(mhk==1)?"Maphacks ON":"Maphacks ON (not found)",0); + enddrawing(); //}}} if (angvel != 0) //ang += angvel * constant { @@ -5678,6 +5717,7 @@ CANCEL: ExtPreLoadMap(); i = loadboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&posx,&posy,&posz,&ang,&cursectnum); + loadmhk(); if (i == -2) i = loadoldboard(boardfilename,(!pathsearchmode&&grponlymode?2:0),&posx,&posy,&posz,&ang,&cursectnum); if (i < 0) { diff --git a/polymer/build/src/engine.c b/polymer/build/src/engine.c index d937c0c24..5ff43d935 100644 --- a/polymer/build/src/engine.c +++ b/polymer/build/src/engine.c @@ -7777,7 +7777,12 @@ void nextpage(void) #ifdef USE_OPENGL omdtims = mdtims; mdtims = getticks(); - if (((unsigned int)(mdtims-omdtims)) > 10000) omdtims = mdtims; + + if(mdpause) + { + int i; + for(i=0;iusesalpha = hasalpha; - - if ((doalloc&3)==1) bglGenTextures(1,(GLuint*)texidx); - bglBindTexture(GL_TEXTURE_2D,*texidx); - - //gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,xsiz,ysiz,GL_BGRA_EXT,GL_UNSIGNED_BYTE,(char *)fptr); - if (glinfo.texcompr && glusetexcompr) intexfmt = hasalpha ? GL_COMPRESSED_RGBA_ARB : GL_COMPRESSED_RGB_ARB; - else if (!hasalpha) intexfmt = GL_RGB; - if (glinfo.bgra) texfmt = GL_BGRA; - uploadtexture((doalloc&1), xsiz, ysiz, intexfmt, texfmt, (coltype*)fptr, xsiz, ysiz, 0); if (pal>=SPECPAL&&pal<=REDPAL) { //_initprintf("%cLoaded palmap %d(%dx%d)",sk->palmap?'+':'-',pal,xsiz,ysiz); @@ -972,6 +963,15 @@ static int mdloadskin(md2model *m, int number, int pal, int surf) cachefil=0; //_initprintf("#%d\n",sk->palmap); } + + if ((doalloc&3)==1) bglGenTextures(1,(GLuint*)texidx); + bglBindTexture(GL_TEXTURE_2D,*texidx); + + //gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,xsiz,ysiz,GL_BGRA_EXT,GL_UNSIGNED_BYTE,(char *)fptr); + if (glinfo.texcompr && glusetexcompr) intexfmt = hasalpha ? GL_COMPRESSED_RGBA_ARB : GL_COMPRESSED_RGB_ARB; + else if (!hasalpha) intexfmt = GL_RGB; + if (glinfo.bgra) texfmt = GL_BGRA; + uploadtexture((doalloc&1), xsiz, ysiz, intexfmt, texfmt, (coltype*)fptr, xsiz, ysiz, 0); free((void*)fptr); } @@ -1046,11 +1046,6 @@ static void updateanimation(md2model *m, spritetype *tspr) int fps; m->cframe = m->nframe = tile2model[Ptile2tile(tspr->picnum,sprite[tspr->owner].pal)].framenum; - if (!mdpause&&spriteext[tspr->owner].oldmdtims!=mdtims) - { - spriteext[tspr->owner].mdanimtims+=max(0,mdtims-omdtims); - spriteext[tspr->owner].oldmdtims=mdtims; - } for (anim = m->animations; anim && anim->startframe != m->cframe; @@ -1061,14 +1056,14 @@ static void updateanimation(md2model *m, spritetype *tspr) { if (spritesmooth[tspr->owner].mdsmooth == 0) { - spriteext[tspr->owner].mdanimtims = 0; + spriteext[tspr->owner].mdanimtims = mdtims; m->interpol = 0; spritesmooth[tspr->owner].mdsmooth = 1; spritesmooth[tspr->owner].mdcurframe = m->cframe; } if (r_animsmoothing && (tile2model[Ptile2tile(tspr->picnum,sprite[tspr->owner].pal)].smoothduration != 0) && (spritesmooth[tspr->owner].mdcurframe != m->cframe)) { - spriteext[tspr->owner].mdanimtims = 0; + spriteext[tspr->owner].mdanimtims = mdtims; m->interpol = 0; spritesmooth[tspr->owner].mdsmooth = 1; spritesmooth[tspr->owner].mdoldframe = spritesmooth[tspr->owner].mdcurframe; @@ -1077,7 +1072,7 @@ static void updateanimation(md2model *m, spritetype *tspr) } else if (r_animsmoothing && (tile2model[Ptile2tile(tspr->picnum,sprite[tspr->owner].pal)].smoothduration != 0) && (spritesmooth[tspr->owner].mdcurframe != m->cframe)) { - spriteext[tspr->owner].mdanimtims = 0; + spriteext[tspr->owner].mdanimtims = mdtims; m->interpol = 0; spritesmooth[tspr->owner].mdsmooth = 1; spritesmooth[tspr->owner].mdoldframe = spritesmooth[tspr->owner].mdcurframe; @@ -1095,7 +1090,7 @@ static void updateanimation(md2model *m, spritetype *tspr) //if (spriteext[tspr->owner].flags & SPREXT_NOMDANIM) OSD_Printf("SPREXT_NOMDANIM\n"); //OSD_Printf("smooth launched ! oldanim %i new anim %i\n", spriteext[tspr->owner].mdanimcur, anim->startframe); spriteext[tspr->owner].mdanimcur = (short)anim->startframe; - spriteext[tspr->owner].mdanimtims = 0; + spriteext[tspr->owner].mdanimtims = mdtims; m->interpol = 0; if (!r_animsmoothing || (tile2model[Ptile2tile(tspr->picnum,sprite[tspr->owner].pal)].smoothduration == 0)) { @@ -1113,14 +1108,14 @@ static void updateanimation(md2model *m, spritetype *tspr) else fps = anim->fpssc; - i = (spriteext[tspr->owner].mdanimtims)*((fps*timerticspersec)/120); + i = (mdtims-spriteext[tspr->owner].mdanimtims)*((fps*timerticspersec)/120); if (spritesmooth[tspr->owner].mdsmooth) j = 65536; else j = ((anim->endframe+1-anim->startframe)<<16); //Just in case you play the game for a VERY int time... - if (i < 0) { i = 0; spriteext[tspr->owner].mdanimtims = 0; } + if (i < 0) { i = 0;spriteext[tspr->owner].mdanimtims = mdtims; } //compare with j*2 instead of j to ensure i stays > j-65536 for MDANIM_ONESHOT if ((anim) && (i >= j+j) && (fps) && !mdpause) //Keep mdanimtims close to mdtims to avoid the use of MOD spriteext[tspr->owner].mdanimtims += j/((fps*timerticspersec)/120); @@ -1138,7 +1133,7 @@ static void updateanimation(md2model *m, spritetype *tspr) //OSD_Printf("smoothing... cframe %i nframe %i\n", m->cframe, m->nframe); if (k > 65535) { - spriteext[tspr->owner].mdanimtims = 0; + spriteext[tspr->owner].mdanimtims = mdtims; m->interpol = 0; spritesmooth[tspr->owner].mdsmooth = 0; m->cframe = m->nframe = (anim) ? anim->startframe : spritesmooth[tspr->owner].mdcurframe; diff --git a/polymer/build/src/polymost.c b/polymer/build/src/polymost.c index 580aca9db..7e85c863b 100644 --- a/polymer/build/src/polymost.c +++ b/polymer/build/src/polymost.c @@ -333,7 +333,7 @@ int dedxtfilter(int fil, texcachepicture *pict, char *pic, void *midbuf, char *p static inline void phex(unsigned char v, char *s); void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *head); -static int mdtims, omdtims; +int mdtims, omdtims; float alphahackarray[MAXTILES]; #include "mdsprite.c" @@ -1779,6 +1779,7 @@ void drawpoly(double *dpx, double *dpy, int n, int method) float hackscx, hackscy; int pal1; + if(usehightile) for (pal1=SPECPAL;pal1<=REDPAL;pal1++) if (hicfindsubst(globalpicnum, pal1, 0)) gltexcache(globalpicnum, pal1, method&(~3)); diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index f8e50254f..72f91283d 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -869,6 +869,7 @@ void CONFIG_WriteSetup(void) Bsprintf(buf,"MouseButtonClicked%d",dummy); SCRIPT_PutString(ud.config.scripthandle,"Controls", buf, CONFIG_FunctionNumToName(ud.config.MouseFunctions[dummy][1])); } + for (dummy=0;dummyz)>>11); tsprite[spritesortcnt].xrepeat = xrep; -// tsprite[spritesortcnt].pal = 4; (shadow will have the same model as its actor) + tsprite[spritesortcnt].pal = 4; yrep = tsprite[spritesortcnt].yrepeat;// - (klabs(daz-t->z)>>11); tsprite[spritesortcnt].yrepeat = yrep; diff --git a/polymer/eduke32/source/savegame.c b/polymer/eduke32/source/savegame.c index 46a8729e3..1e260a541 100644 --- a/polymer/eduke32/source/savegame.c +++ b/polymer/eduke32/source/savegame.c @@ -234,6 +234,9 @@ int loadplayer(int spot) if (kdfread(§or[0],sizeof(sectortype),MAXSECTORS,fil) != MAXSECTORS) goto corrupt; if (kdfread(&sprite[0],sizeof(spritetype),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; if (kdfread(&spriteext[0],sizeof(spriteexttype),MAXSPRITES,fil) != MAXSPRITES) goto corrupt; +#if defined(POLYMOST) && defined(USE_OPENGL) + for(i=0;i