diff --git a/src/switch.c b/src/switch.c
index 275aed721c9c13437bd38955260f5c70093e3863..886bee934096b71df73538dbd69580096c898988 100644 (file)
--- a/src/switch.c
+++ b/src/switch.c
-/*
- Copyright (C) Prikol Software 1996-1997
- Copyright (C) Aleksey Volynskov 1996-1997
- Copyright (C) <ARembo@gmail.com> 2011
-
- This file is part of the Doom2D:Rembo project.
-
- Doom2D:Rembo is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- Doom2D:Rembo is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/> or
- write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+/* Copyright (C) 1996-1997 Aleksey Volynskov
+ * Copyright (C) 2011 Rambo
+ * Copyright (C) 2020 SovietPony
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include "glob.h"
#include <string.h>
#include "player.h"
#include "misc.h"
#include "map.h"
-
-#define MAXSW 100
-
-extern map_block_t blk;
-
-#pragma pack(1)
-typedef struct{
- byte x,y;
- byte t,tm;
- byte a,b,c,d;
- byte f;
-}sw_t;
-#pragma pack()
-
-static sw_t sw[MAXSW];
-
-static void *sndswn,*sndswx,*sndnoway,*sndbdo,*sndbdc,*sndnotele;
-static int swsnd;
+#include "files.h"
+#include "game.h"
+#include "my.h"
+#include "monster.h"
+#include "render.h"
int sw_secrets;
+sw_t sw[MAXSW];
-void SW_savegame (FILE *h) {
- int i, n;
- for (n = MAXSW - 1; n >= 0 && sw[n].t == 0; n--) {
- // empty
- }
- n += 1;
- myfwrite32(n, h);
- for (i = 0; i < n; i++) {
- myfwrite8(sw[i].x, h);
- myfwrite8(sw[i].y, h);
- myfwrite8(sw[i].t, h);
- myfwrite8(sw[i].tm, h);
- myfwrite8(sw[i].a, h);
- myfwrite8(sw[i].b, h);
- myfwrite8(sw[i].c, h);
- myfwrite8(sw[i].d, h);
- myfwrite8(sw[i].f, h);
- }
- myfwrite32(sw_secrets, h);
-}
-
-void SW_loadgame (FILE *h) {
- int i, n;
- myfread32(&n, h);
- for (i = 0; i < n; i++) {
- myfread8(&sw[i].x, h);
- myfread8(&sw[i].y, h);
- myfread8(&sw[i].t, h);
- myfread8(&sw[i].tm, h);
- myfread8(&sw[i].a, h);
- myfread8(&sw[i].b, h);
- myfread8(&sw[i].c, h);
- myfread8(&sw[i].d, h);
- myfread8(&sw[i].f, h);
- }
- myfread32(&sw_secrets, h);
-}
-
-int SW_load (FILE *h) {
- int i;
- switch(blk.t) {
- case MB_SWITCH2:
- sw_secrets = 0;
- for (i = 0; i < MAXSW && blk.sz > 0; ++i, blk.sz -= 9) {
- myfread8(&sw[i].x, h);
- myfread8(&sw[i].y, h);
- myfread8(&sw[i].t, h);
- myfread8(&sw[i].tm, h); // unused
- myfread8(&sw[i].a, h);
- myfread8(&sw[i].b, h);
- myfread8(&sw[i].c, h);
- myfread8(&sw[i].d, h); // unused
- myfread8(&sw[i].f, h);
- sw[i].tm = 0;
- sw[i].d = 0;
- sw[i].f |= 0x80;
- if (sw[i].t == SW_SECRET) {
- ++sw_secrets;
- }
- }
- return 1;
- }
- return 0;
-}
+static void *sndswn, *sndswx, *sndnoway, *sndbdo, *sndbdc, *sndnotele;
+static int swsnd;
+static byte cht, chto, chf, f_ch;
-void SW_alloc(void) {
+void SW_alloc (void) {
sndswn=Z_getsnd("SWTCHN");
sndswx=Z_getsnd("SWTCHX");
sndnoway=Z_getsnd("NOWAY");
sndnotele=Z_getsnd("NOTELE");
}
-void SW_init(void) {
+void SW_init (void) {
int i;
-
- for(i=0;i<MAXSW;++i) sw[i].t=0;
- swsnd=0;
+ for (i = 0; i < MAXSW; i++) {
+ sw[i].t = 0;
+ }
+ swsnd = 0;
}
-static byte cht,chto,chf,f_ch;
-
static void door(byte x,byte y) {
byte ex;
}
}
-void Z_water_trap(obj_t *o) {
+void Z_water_trap (obj_t *o) {
int i,j,sx,sy,x,y;
if((y=o->y)>=FLDH*CELH+o->h) return;
}
}
-void Z_untrap(byte t) {
+void Z_untrap (byte t) {
byte *p;
word n;
return 1;
}
-void SW_act(void) {
+void SW_act (void) {
int i;
if(swsnd) --swsnd;
return 0;
}
-void SW_cheat_open(void) {
+void SW_cheat_open (void) {
int i;
for(i=0;i<MAXSW;++i) if(sw[i].t && !sw[i].tm) switch(sw[i].t) {
}
}
-int SW_press(int x,int y,int r,int h,byte t,int o) {
+int SW_press (int x, int y, int r, int h, byte t, int o) {
int sx,sy,i,p;
sx=(x-r)/CELW;sy=(y-h+1)/CELH;
else ++pl2.secrets;
sw[i].tm=1;sw[i].t=0;break;
}
- if(sw[i].tm)
- {fldb[sw[i].y][sw[i].x]=walswp[fldb[sw[i].y][sw[i].x]];p=1;}
+ if (sw[i].tm != 0) {
+ R_switch_texture(sw[i].x, sw[i].y);
+ p = 1;
+ }
if(sw[i].tm==1) sw[i].tm=0;
}
}