ref: 30670c674ee6ae1f468e1ac29b66e0480a113ede
parent: f15fe15ed46c560214d68359a6b39c49cbce7fdd
author: fabien sanglard <[email protected]>
date: Sat Dec 22 13:53:48 EST 2012
Added tile utility: TILE_MakeAvailable
--- a/Engine/src/engine.c
+++ b/Engine/src/engine.c
@@ -744,8 +744,7 @@
if (tiles[globalpicnum].animFlags&192)
globalpicnum += animateoffs(globalpicnum);
- if (tiles[globalpicnum].data == NULL)
- loadtile(globalpicnum);
+ TILE_MakeAvailable(globalpicnum);
globalbufplc = tiles[globalpicnum].data;
@@ -983,8 +982,7 @@
globalpicnum += animateoffs(globalpicnum);
//If the texture is not in RAM: Load it !!
- if (tiles[globalpicnum].data == NULL)
- loadtile(globalpicnum);
+ TILE_MakeAvailable(globalpicnum);
//Check where is the texture in RAM
globalbufplc = tiles[globalpicnum].data;
@@ -1251,8 +1249,7 @@
if ((dwal[x1] < 0) && (dwal[x2] < 0))
return;
- if (tiles[globalpicnum].data == NULL)
- loadtile(globalpicnum);
+ TILE_MakeAvailable(globalpicnum);
xnice = (pow2long[picsiz[globalpicnum]&15] == tileWidth);
if (xnice)
@@ -1438,8 +1435,7 @@
if ((dwal[x1] < 0) && (dwal[x2] < 0))
return;
- if (tiles[globalpicnum].data == NULL)
- loadtile(globalpicnum);
+ TILE_MakeAvailable(globalpicnum);
startx = x1;
@@ -1770,8 +1766,7 @@
(tiles[globalpicnum].dim.height <= 0))
return;
- if (tiles[globalpicnum].data == NULL)
- loadtile(globalpicnum);
+ TILE_MakeAvailable(globalpicnum);
wal = &wall[sec->wallptr];
wx = wall[wal->point2].x - wal->x;
@@ -3174,7 +3169,7 @@
(tiles[globalpicnum].dim.height <= 0))
return;
- if (tiles[globalpicnum].data == NULL) loadtile(globalpicnum);
+ TILE_MakeAvailable(globalpicnum);
x = x1;
while ((startumost[x+windowx1] > startdmost[x+windowx1]) && (x <= x2)) x++;
@@ -3872,8 +3867,7 @@
nextv = v;
}
- if (tiles[picnum].data == NULL)
- loadtile(picnum);
+ TILE_MakeAvailable(globalpicnum);
setgotpic(picnum);
bufplc = tiles[picnum].data;
@@ -5555,8 +5549,7 @@
if ((uint32_t)globalpicnum >= (uint32_t)MAXTILES)
globalpicnum = 0;
- if (tiles[globalpicnum].data == NULL)
- loadtile(globalpicnum);
+ TILE_MakeAvailable(globalpicnum);
setgotpic(globalpicnum);
globalbufplc = tiles[globalpicnum].data;
@@ -8643,8 +8636,7 @@
if ((tiles[globalpicnum].animFlags&192) != 0)
globalpicnum += animateoffs(globalpicnum);
- if (tiles[globalpicnum].data == NULL)
- loadtile(globalpicnum);
+ TILE_MakeAvailable(globalpicnum);
globalbufplc = tiles[globalpicnum].data;
@@ -8828,8 +8820,7 @@
if ((tiles[globalpicnum].animFlags&192) != 0)
globalpicnum += animateoffs(globalpicnum);
- if (tiles[globalpicnum].data == NULL)
- loadtile(globalpicnum);
+ TILE_MakeAvailable(globalpicnum);
globalbufplc = tiles[globalpicnum].data;
if ((sector[spr->sectnum].ceilingstat&1) > 0)
--- a/Engine/src/tiles.c
+++ b/Engine/src/tiles.c
@@ -72,7 +72,7 @@
k = (tileDim.width<<1);
for(i=tileDim.width-1; i>=0; i--)
{
- ptr1 = (uint8_t *) (tiles[tilenume].data+i*(tileDim.width+1));
+ ptr1 = tiles[tilenume].data+i*(tileDim.width+1);
ptr2 = ptr1;
if ((i&1) != 0) {
ptr1--;
@@ -260,9 +260,10 @@
}
}
while (k != numtilefiles);
+
printf("Art files loaded\n");
- clearbuf(&gotpic[0],(int32_t)((MAXTILES+31)>>5),0L);
+ clearbuf(gotpic,(MAXTILES+31)>>5,0L);
/* try dpmi_DETERMINEMAXREALALLOC! */
@@ -277,10 +278,15 @@
for(i=0; i<MAXTILES; i++)
{
j = 15;
- while ((j > 1) && (pow2long[j] > tiles[i].dim.width)) j--;
+ while ((j > 1) && (pow2long[j] > tiles[i].dim.width))
+ j--;
+
picsiz[i] = ((uint8_t )j);
j = 15;
- while ((j > 1) && (pow2long[j] > tiles[i].dim.height)) j--;
+
+ while ((j > 1) && (pow2long[j] > tiles[i].dim.height))
+ j--;
+
picsiz[i] += ((uint8_t )(j<<4));
}
@@ -292,7 +298,11 @@
}
+void TILE_MakeAvailable(short picID){
+ if (tiles[picID].data == NULL)
+ loadtile(picID);
+}
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)
@@ -302,17 +312,16 @@
xsiz1 = tiles[tilenume1].dim.width;
ysiz1 = tiles[tilenume1].dim.height;
+
xsiz2 = tiles[tilenume2].dim.width;
ysiz2 = tiles[tilenume2].dim.height;
+
if ((xsiz1 > 0) && (ysiz1 > 0) && (xsiz2 > 0) && (ysiz2 > 0))
{
- if (tiles[tilenume1].data == NULL)
- loadtile((short) tilenume1);
+ TILE_MakeAvailable(tilenume1);
+ TILE_MakeAvailable(tilenume2);
- if (tiles[tilenume2].data == NULL)
- loadtile((short) tilenume2);
-
x1 = sx1;
for(i=0; i<xsiz; i++)
{
@@ -323,9 +332,11 @@
y2 = sy2+j;
if ((x2 >= 0) && (y2 >= 0) && (x2 < xsiz2) && (y2 < ysiz2))
{
- ptr1 = (uint8_t *) (tiles[tilenume1].data + x1*ysiz1 + y1);
- ptr2 = (uint8_t *) (tiles[tilenume2].data + x2*ysiz2 + y2);
+ ptr1 = tiles[tilenume1].data + x1*ysiz1 + y1;
+ ptr2 = tiles[tilenume2].data + x2*ysiz2 + y2;
dat = *ptr1;
+
+
if (dat != 255)
*ptr2 = *ptr1;
}
--- a/Engine/src/tiles.h
+++ b/Engine/src/tiles.h
@@ -68,4 +68,6 @@
extern uint8_t *pic ;
+void TILE_MakeAvailable(short picID);
+
#endif
--- a/Game/src/player.c
+++ b/Game/src/player.c
@@ -2342,6 +2342,7 @@
short psect, psectlotag,*kb, tempsect, pi;
struct player_struct *p;
spritetype *s;
+ char text[512];
p = &ps[snum];
pi = p->i;
@@ -2609,8 +2610,8 @@
if(myconnectindex == connecthead)
{
- sprintf(tempbuf,"frag %d killed %d\n",p->frag_ps+1,snum+1);
- sendscore(tempbuf);
+ sprintf(text,"frag %d killed %d\n",p->frag_ps+1,snum+1);
+ sendscore(text);
// printf(tempbuf);
}
--- a/Game/src/premap.c
+++ b/Game/src/premap.c
@@ -133,7 +133,7 @@
{
maxc = 5;
for(j = 1420;j < 1420+106; j++)
- if(tiles[j].data == -1)
+ if(tiles[j].data == NULL)
tloadtile(j);
}
break;