DEADSOFTWARE

fix some warnings
[flatwaifu.git] / src / game.c
index 194365ecc3a739663131a9eedb7c5f5b87a8705c..353ed539552dd0e3dc9ba049bc2739f927962f8c 100644 (file)
@@ -27,7 +27,6 @@
 #include "files.h"
 #include "memory.h"
 #include "vga.h"
-#include "error.h"
 #include "keyb.h"
 #include "sound.h"
 #include "view.h"
@@ -43,6 +42,7 @@
 #include "menu.h"
 #include "misc.h"
 #include "map.h"
+#include "my.h"
 
 #include <SDL_keysym.h>
 
@@ -80,7 +80,8 @@ extern byte clrmap[256*12];
 
 extern byte cheat;
 
-byte _2pl=0,g_dm=0,g_st=GS_TITLE,g_exit=0,g_map=1,_warp=0,g_music[8]="MENU";
+byte _2pl=0,g_dm=0,g_st=GS_TITLE,g_exit=0,g_map=1,_warp=0;
+char g_music[8]="MENU";
 byte _net=0;
 int g_sttm=1092;
 dword g_time;
@@ -113,29 +114,57 @@ static void set_trans(int st) {
 }
 
 void G_savegame(FILE* h) {
-  myfwrite(&_2pl,1,1,h);myfwrite(&g_dm,1,1,h);myfwrite(&g_exit,1,1,h);myfwrite(&g_map,1,1,h);
-  myfwrite(&g_time,1,4,h);myfwrite(&dm_pl1p,1,4,h);myfwrite(&dm_pl2p,1,4,h);
-  myfwrite(&dm_pnum,1,4,h);myfwrite(dm_pos,1,dm_pnum*sizeof(pos_t),h);
-  myfwrite(&cheat,1,1,h);
-  myfwrite(g_music,1,8,h);
+  myfwrite8(_2pl, h);
+  myfwrite8(g_dm, h);
+  myfwrite8(g_exit, h);
+  myfwrite8(g_map, h);
+  myfwrite32(g_time, h);
+  myfwrite32(dm_pl1p, h);
+  myfwrite32(dm_pl2p, h);
+  myfwrite32(dm_pnum, h);
+  int i = 0;
+  while (i < dm_pnum) {
+    myfwrite32(dm_pos[i].x, h);
+    myfwrite32(dm_pos[i].y, h);
+    myfwrite8(dm_pos[i].d, h);
+    i += 1;
+  }
+  myfwrite8(cheat, h);
+  myfwrite(g_music, 8, 1, h);
 }
 
 void G_loadgame(FILE* h) {
-  myfread(&_2pl,1,1,h);myfread(&g_dm,1,1,h);myfread(&g_exit,1,1,h);myfread(&g_map,1,1,h);
-  myfread(&g_time,1,4,h);myfread(&dm_pl1p,1,4,h);myfread(&dm_pl2p,1,4,h);
-  myfread(&dm_pnum,1,4,h);myfread(dm_pos,1,dm_pnum*sizeof(pos_t),h);
-  myfread(&cheat,1,1,h);
-  myfread(g_music,1,8,h);F_loadmus(g_music);
+  _2pl = myfread8(h);
+  g_dm = myfread8(h);
+  g_exit = myfread8(h);
+  g_map = myfread8(h);
+  g_time = myfread32(h);
+  dm_pl1p = myfread32(h);
+  dm_pl2p = myfread32(h);
+  dm_pnum = myfread32(h);
+  int i = 0;
+  while (i < dm_pnum) {
+    dm_pos[i].x = myfread32(h);
+    dm_pos[i].y = myfread32(h);
+    dm_pos[i].d = myfread8(h);
+    i += 1;
+  }
+  cheat = myfread8(h);
+  myfread(g_music, 8, 1, h);
+  F_loadmus(g_music);
 }
 
-int G_load(FILE* h) {
-  switch(blk.t) {
+int G_load (FILE *h) {
+  switch (blk.t) {
        case MB_MUSIC:
-         myfread(g_music,1,8,h);
-         if (music_random) F_randmus(g_music);
-          F_loadmus(g_music);
+         myfread(g_music, 8, 1, h);
+         if (music_random) {
+      F_randmus(g_music);
+    }
+    F_loadmus(g_music);
          return 1;
-  }return 0;
+  }
+  return 0;
 }
 
 void load_game(int n) {
@@ -196,10 +225,10 @@ void G_init(void) {
   logo("G_init: настройка ресурсов игры ");
   logo_gas(5,GGAS_TOTAL);
   telepsnd=Z_getsnd("TELEPT");
-  scrnh[0]=M_lock(F_getresid("TITLEPIC"));
-  scrnh[1]=M_lock(F_getresid("INTERPIC"));
-  scrnh[2]=M_lock(F_getresid("ENDPIC"));
-  cd_scr=M_lock(F_getresid("CD1PIC"));
+  scrnh[0]=V_loadvgaimg("TITLEPIC");
+  scrnh[1]=V_loadvgaimg("INTERPIC");
+  scrnh[2]=V_loadvgaimg("ENDPIC");
+  cd_scr=V_loadvgaimg("CD1PIC");
   for(i=0;i<2;++i) {
     sprintf(s,"LTN%c",i+'1');
     for(j=0;j<2;++j)