DEADSOFTWARE

headers describes that c-files implements
[flatwaifu.git] / src / config.c
index fbfadc0c9fb9941543bf8fe018d393082c3474ab..0c5bc21868319394f1645d5d800437f29bcb6588 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-//#include <process.h>
-//#include <dos.h>
-#include "config.h"
-#include "vga.h"
-#include "error.h"
+#include <SDL_keyboard.h>
+#include "map.h"
 #include "sound.h"
-#include "keyb.h"
-#include "files.h"
-#include "memory.h"
+#include "music.h"
 #include "view.h"
+#include "monster.h"
 #include "player.h"
+#include "menu.h"
+#include "files.h"
+#include "render.h"
+#include "error.h"
 #include "my.h"
 
-#include <SDL_keyboard.h>
-
-extern byte _warp,fastdraw,nomon;
-extern int mem_chk_sz;
-
 enum{NONE,BYTE,WORD,DWORD,STRING,SW_ON,SW_OFF,FILES,KEY};
 
 typedef struct{
@@ -50,13 +45,12 @@ typedef struct{
   byte t,o;
 }cfg_t;
 
-
 byte cheat=0;
-
 byte shot_vga=0;
-
-
 char cd_path[128]="";
+char cfg_file[128]="default.cfg";
+
+static char buf[256];
 
 static cfg_t cfg[]={
   {"file",NULL,NULL,FILES,0},
@@ -64,11 +58,11 @@ static cfg_t cfg[]={
   {"vga","screenshot",&shot_vga,SW_ON,0},
   {"sndvol","sound_volume",&snd_vol,WORD,0},
   {"musvol","music_volume",&mus_vol,WORD,0},
-  {"fullscr","fullscreen",&fullscreen,SW_ON,0},
-  {"window",NULL,&fullscreen,SW_OFF,0},
+//  {"fullscr","fullscreen",&fullscreen,SW_ON,0},
+//  {"window",NULL,&fullscreen,SW_OFF,0},
   {NULL,"sky",&w_horiz,SW_ON,0},
   {"mon",NULL,&nomon,SW_OFF,0},
-  {"gamma","gamma",&gammaa,DWORD,0},
+//  {"gamma","gamma",&gammaa,DWORD,0},
   {"warp",NULL,&_warp,BYTE,0},
   {"width","screen_width",&SCRW,DWORD,0},
   {"height","screen_height",&SCRH,DWORD,0},
@@ -97,11 +91,6 @@ static cfg_t cfg[]={
   {NULL,NULL,NULL,NONE,0}
 };
 
-
-char cfg_file[128]="default.cfg";
-
-static char buf[256];
-
 void CFG_args(int argc, char *argv[]) {
   int j;
   dword n;
@@ -165,8 +154,7 @@ next:
   }
 }
 
-int get_key(char *name)
-{
+static int get_key (char *name) {
     int i;
     for(i=1; i<SDLK_LAST; i++) {
         char* s = SDL_GetKeyName(i);
@@ -206,43 +194,51 @@ void CFG_load(void) {
   }
   while(!feof(h)) {
     F_readstr(h,s,127);
-       if(*s==';' || s[1]==';') continue; // comment
-    if(!(p1=strtok(s,"\r\n\t=;"))) continue;//if(!(p1=strtok(s,"\r\n\t =;"))) continue;
-    if(!(p2=strtok(NULL,"\r\n\t=;"))) continue;//if(!(p2=strtok(NULL,"\r\n\t =;"))) continue;
-    for(j=0;cfg[j].t;++j) if(cfg[j].cfg && !cfg[j].o)
-     if(strcasecmp(p1,cfg[j].cfg)==0) {
-      switch(cfg[j].t) {
-       case BYTE:
-         n=strtol(p2,NULL,0);
-         *((byte *)cfg[j].p)=(byte)n;
-         break;
-       case WORD:
-         n=strtol(p2,NULL,0);
-         *((word *)cfg[j].p)=(word)n;
-         break;
-       case DWORD:
-         n=strtol(p2,NULL,0);
-         *((dword *)cfg[j].p)=n;
-         break;
-       case STRING:
-         strcpy((char *)cfg[j].p,p2);
-         break;
-       case SW_ON:
-       case SW_OFF:
-         if(strcasecmp(p2,"ON")==0) {*((byte *)cfg[j].p)=ON;break;}
-         if(strcasecmp(p2,"OFF")==0) {*((byte *)cfg[j].p)=OFF;break;}
-         *((byte *)cfg[j].p)=strtol(p2,NULL,0);
-         break;
-       case FILES:
-         break;
-
-        case KEY:
-        {
-            int k = get_key(p2);
-            if (k) {
-                *((int *)cfg[j].p)=k;
-            }
-            else {
+    if(*s==';' || s[1]==';')
+      continue; // comment
+    if(!(p1=strtok(s,"\r\n\t=;")))
+      continue; //if(!(p1=strtok(s,"\r\n\t =;"))) continue;
+    if(!(p2=strtok(NULL,"\r\n\t=;")))
+      continue;//if(!(p2=strtok(NULL,"\r\n\t =;"))) continue;
+    for(j=0;cfg[j].t;++j) {
+      if(cfg[j].cfg && !cfg[j].o) {
+        if(strcasecmp(p1,cfg[j].cfg)==0) {
+          switch(cfg[j].t) {
+          case BYTE:
+            n=strtol(p2,NULL,0);
+            *((byte *)cfg[j].p)=(byte)n;
+            break;
+          case WORD:
+            n=strtol(p2,NULL,0);
+            *((word *)cfg[j].p)=(word)n;
+            break;
+          case DWORD:
+            n=strtol(p2,NULL,0);
+            *((dword *)cfg[j].p)=n;
+            break;
+          case STRING:
+            strcpy((char *)cfg[j].p,p2);
+            break;
+          case SW_ON:
+          case SW_OFF:
+            if(strcasecmp(p2,"ON")==0) {
+            *((byte *)cfg[j].p)=ON;
+            break;
+          }
+          if(strcasecmp(p2,"OFF")==0) {
+            *((byte *)cfg[j].p)=OFF;
+            break;
+          }
+          *((byte *)cfg[j].p)=strtol(p2,NULL,0);
+          break;
+          case FILES:
+            break;
+          case KEY:
+          {
+              int k = get_key(p2);
+              if (k) {
+                  *((int *)cfg[j].p)=k;
+              } else {
                 logo("Unknown key in cfg: %s=%s\n",p1,p2);
                 logo("List available key names:\n");
                 int i;
@@ -253,16 +249,17 @@ void CFG_load(void) {
                         logo("%s\n", s);
                     }
                 }
-            }
-        }
-        break;
-
-       default:
-         ERR_failinit("!!! Неизвестный тип в cfg !!!");
-         }
-         break;
-    }
-  }
+              }
+          }
+          break;
+          default:
+            ERR_failinit("!!! Неизвестный тип в cfg !!!");
+          } // switch
+          break;
+        } // if
+      } // if
+    } // for
+  } // while
   fclose(h);
 }