⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dehacked.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 2 页
字号:
    s[len1]='\0';    deh_error("Text not changed :%s\n",s);  }}/*Ammo type = 2Deselect frame = 11Select frame = 12Bobbing frame = 13Shooting frame = 17Firing frame = 10*/static void readweapon(MYFILE *f,int num){  char s[MAXLINELEN];  char *word;  int value;  do{    if(myfgets(s,sizeof(s),f)!=NULL)    {      if(s[0]=='\n') break;      value=searchvalue(s);      word=strtok(s," ");           if(!strcmp(word,"Ammo"))       doomweaponinfo[num].ammo      =value;      else if(!strcmp(word,"Deselect"))   doomweaponinfo[num].upstate   =value;      else if(!strcmp(word,"Select"))     doomweaponinfo[num].downstate =value;      else if(!strcmp(word,"Bobbing"))    doomweaponinfo[num].readystate=value;      else if(!strcmp(word,"Shooting"))   doomweaponinfo[num].atkstate  = doomweaponinfo[num].holdatkstate = value;      else if(!strcmp(word,"Firing"))     doomweaponinfo[num].flashstate=value;      else deh_error("Weapon %d : unknow word '%s'\n",num,word);    }  } while(s[0]!='\n' && !myfeof(f));}/*Max ammo = 400Per ammo = 40*/extern int clipammo[];extern int GetWeaponAmmo[];static void readammo(MYFILE *f,int num){  char s[MAXLINELEN];  char *word;  int value;  do{    if(myfgets(s,sizeof(s),f)!=NULL)    {      if(s[0]=='\n') break;      value=searchvalue(s);      word=strtok(s," ");           if(!strcmp(word,"Max"))  maxammo[num] =value;      else if(!strcmp(word,"Per")) { clipammo[num]=value;GetWeaponAmmo[num] = 2*value; }      else if(!strcmp(word,"Perweapon")) GetWeaponAmmo[num] = 2*value;       else deh_error("Ammo %d : unknow word '%s'\n",num,word);    }  } while(s[0]!='\n' && !myfeof(f));}// i don't like that but do you see a other way ?extern int idfa_armor;extern int idfa_armor_class;extern int idkfa_armor;extern int idkfa_armor_class;extern int god_health;extern int initial_health;extern int initial_bullets;extern int MAXHEALTH;extern int max_armor;extern int green_armor_class;extern int blue_armor_class;extern int maxsoul;extern int soul_health;extern int mega_health;static void readmisc(MYFILE *f){  char s[MAXLINELEN];  char *word,*word2;  int value;  do{    if(myfgets(s,sizeof(s),f)!=NULL)    {      if(s[0]=='\n') break;      value=searchvalue(s);      word=strtok(s," ");      word2=strtok(NULL," ");      if(!strcmp(word,"Initial"))      {         if(!strcmp(word2,"Health"))          initial_health=value;         else if(!strcmp(word2,"Bullets"))    initial_bullets=value;      }      else if(!strcmp(word,"Max"))      {         if(!strcmp(word2,"Health"))          MAXHEALTH=value;         else if(!strcmp(word2,"Armor"))      max_armor=value;         else if(!strcmp(word2,"Soulsphere")) maxsoul=value;      }      else if(!strcmp(word,"Green"))         green_armor_class=value;      else if(!strcmp(word,"Blue"))          blue_armor_class=value;      else if(!strcmp(word,"Soulsphere"))    soul_health=value;      else if(!strcmp(word,"Megasphere"))    mega_health=value;      else if(!strcmp(word,"God"))           god_health=value;      else if(!strcmp(word,"IDFA"))      {         word2=strtok(NULL," ");         if(!strcmp(word2,"="))               idfa_armor=value;         else if(!strcmp(word2,"Class"))      idfa_armor_class=value;      }      else if(!strcmp(word,"IDKFA"))      {         word2=strtok(NULL," ");         if(!strcmp(word2,"="))               idkfa_armor=value;         else if(!strcmp(word2,"Class"))      idkfa_armor_class=value;      }      else if(!strcmp(word,"BFG"))            doomweaponinfo[wp_bfg].ammopershoot = value;      else if(!strcmp(word,"Monsters"))      {} // i don't found where is implemented      else deh_error("Misc : unknow word '%s'\n",word);    }  } while(s[0]!='\n' && !myfeof(f));}extern byte cheat_mus_seq[];extern byte cheat_choppers_seq[];extern byte cheat_god_seq[];extern byte cheat_ammo_seq[];extern byte cheat_ammonokey_seq[];extern byte cheat_noclip_seq[];extern byte cheat_commercial_noclip_seq[];extern byte cheat_powerup_seq[7][10];extern byte cheat_clev_seq[];extern byte cheat_mypos_seq[];extern byte cheat_amap_seq[];static void change_cheat_code(char *cheatseq,char* newcheat){  unsigned char *i,*j;  // encript data  for(i=newcheat;i[0]!='\0';i++)      i[0]=SCRAMBLE(i[0]);  for(i=cheatseq,j=newcheat;j[0]!='\0' && j[0]!=0xff;i++,j++)      if(i[0]==1 || i[0]==0xff) // no more place in the cheat      {         deh_error("Cheat too long\n");         return;      }      else         i[0]=j[0];  // newcheatseq < oldcheat  j=i;  // search special cheat with 100  for(;i[0]!=0xff;i++)      if(i[0]==1)      {         *j++=1;         *j++=0;         *j++=0;         break;      }  *j=0xff;  return;}static void readcheat(MYFILE *f){  char s[MAXLINELEN];  char *word,*word2;  char *value;  do{    if(myfgets(s,sizeof(s),f)!=NULL)    {      if(s[0]=='\n') break;      strtok(s,"=");      value=strtok(NULL," \n");         // skip the space      strtok(NULL," \n");              // finish the string      word=strtok(s," ");      if(!strcmp(word     ,"Change"))        change_cheat_code(cheat_mus_seq,value);      else if(!strcmp(word,"Chainsaw"))      change_cheat_code(cheat_choppers_seq,value);      else if(!strcmp(word,"God"))           change_cheat_code(cheat_god_seq,value);      else if(!strcmp(word,"Ammo"))           {             word2=strtok(NULL," ");             if(word2 && !strcmp(word2,"&")) change_cheat_code(cheat_ammo_seq,value);             else                            change_cheat_code(cheat_ammonokey_seq,value);           }      else if(!strcmp(word,"No"))           {             word2=strtok(NULL," ");             if(word2)                word2=strtok(NULL," ");             if(word2 && !strcmp(word2,"1")) change_cheat_code(cheat_noclip_seq,value);             else                            change_cheat_code(cheat_commercial_noclip_seq,value);           }      else if(!strcmp(word,"Invincibility")) change_cheat_code(cheat_powerup_seq[0],value);      else if(!strcmp(word,"Berserk"))       change_cheat_code(cheat_powerup_seq[1],value);      else if(!strcmp(word,"Invisibility"))  change_cheat_code(cheat_powerup_seq[2],value);      else if(!strcmp(word,"Radiation"))     change_cheat_code(cheat_powerup_seq[3],value);      else if(!strcmp(word,"Auto-map"))      change_cheat_code(cheat_powerup_seq[4],value);      else if(!strcmp(word,"Lite-Amp"))      change_cheat_code(cheat_powerup_seq[5],value);      else if(!strcmp(word,"BEHOLD"))        change_cheat_code(cheat_powerup_seq[6],value);      else if(!strcmp(word,"Level"))         change_cheat_code(cheat_clev_seq,value);      else if(!strcmp(word,"Player"))        change_cheat_code(cheat_mypos_seq,value);      else if(!strcmp(word,"Map"))           change_cheat_code(cheat_amap_seq,value);      else deh_error("Cheat : unknow word '%s'\n",word);    }  } while(s[0]!='\n' && !myfeof(f));}void DEH_LoadDehackedFile(MYFILE* f){    char       s[1000];  char       *word,*word2;  int        i;  // do a copy of this for cross references probleme  actionf_t  saveactions[NUMSTATES];  char       *savesprnames[NUMSPRITES];  char       *savesfxnames[NUMSFX];  deh_num_error=0;  // save value for cross reference  for(i=0;i<NUMSTATES;i++)      saveactions[i]=states[i].action;  for(i=0;i<NUMSPRITES;i++)      savesprnames[i]=sprnames[i];  for(i=0;i<NUMSFX;i++)      savesfxnames[i]=S_sfx[i].name;  // it don't test the version of doom  // and version of dehacked file  while(!myfeof(f))  {    myfgets(s,sizeof(s),f);    if(s[0]=='\n' || s[0]=='#')      continue;    word=strtok(s," ");    if(word!=NULL)    {      if((word2=strtok(NULL," "))!=NULL)      {        i=atoi(word2);        if(!strcmp(word,"Thing"))        {          i--; // begin at 0 not 1;          if(i<NUMMOBJTYPES && i>=0)            readthing(f,i);          else            deh_error("Thing %d don't exist\n",i);        }        else if(!strcmp(word,"Frame"))             {               if(i<NUMSTATES && i>=0)                  readframe(f,i);               else                  deh_error("Frame %d don't exist\n",i);             }        else if(!strcmp(word,"Pointer"))             {               word=strtok(NULL," "); // get frame               if((word=strtok(NULL,")"))!=NULL)               {                 i=atoi(word);                 if(i<NUMSTATES && i>=0)                 {                   if(myfgets(s,sizeof(s),f)!=NULL)                     states[i].action=saveactions[searchvalue(s)];                 }                 else                    deh_error("Pointer : Frame %d don't exist\n",i);               }               else                   deh_error("pointer (Frame %d) : missing ')'\n",i);             }        else if(!strcmp(word,"Sound"))             {               if(i<NUMSFX && i>=0)                   readsound(f,i,savesfxnames);               else                   deh_error("Sound %d don't exist\n");             }        else if(!strcmp(word,"Sprite"))             {               if(i<NUMSPRITES && i>=0)               {                 if(myfgets(s,sizeof(s),f)!=NULL)                 {                   int k;                   k=(searchvalue(s)-151328)/8;                   if(k>=0 && k<NUMSPRITES)                       sprnames[i]=savesprnames[k];                   else                       deh_error("Sprite %i : offset out of bound\n",i);                 }               }               else                  deh_error("Sprite %d don't exist\n",i);             }        else if(!strcmp(word,"Text"))             {               int j;               if((word=strtok(NULL," "))!=NULL)               {                 j=atoi(word);                 readtext(f,i,j,savesfxnames,savesprnames);               }               else                   deh_error("Text : missing second number\n");             }        else if(!strcmp(word,"Weapon"))             {               if(i<NUMWEAPONS && i>=0)                   readweapon(f,i);               else                   deh_error("Weapon %d don't exist\n",i);             }        else if(!strcmp(word,"Ammo"))             {               if(i<NUMAMMO && i>=0)                   readammo(f,i);               else                   deh_error("Ammo %d don't exist\n",i);             }        else if(!strcmp(word,"Misc"))               readmisc(f);        else if(!strcmp(word,"Cheat"))               readcheat(f);        else if(!strcmp(word,"Doom"))             {               int ver = searchvalue(strtok(NULL,"\n"));               if( ver!=19)                  deh_error("Warning : patch from a different doom version (%d), only verion 1.9 is supported\n",ver);             }        else if(!strcmp(word,"Patch"))             {               word=strtok(NULL," ");               if(word && !strcmp(word,"format"))               {                  if(searchvalue(strtok(NULL,"\n"))!=6)                     deh_error("Warning : Patch format not supported");               }             }        //SoM: Support for Boom Extras (BEX)/*        else if(!strcmp(word, "[STRINGS]"))             {             }        else if(!strcmp(word, "[PARS]"))             {             }        else if(!strcmp(word, "[CODEPTR]"))             {             }*/        else deh_error("Unknow word : %s\n",word);      }      else          deh_error("missing argument for '%s'\n",word);    }    else        deh_error("No word in this line:\n%s\n",s);  } // end while  if (deh_num_error>0)  {      CONS_Printf("%d warning(s) in the dehacked file\n",deh_num_error);      if (devparm)          getchar();  }  deh_loaded = true;}//SoM: 4/4/2000: Loads a DeHackEd lump from a wad file, saves it to a temp//file and calls LoadDehackedFile. I don't know how well this method will//work on Linux or Win32 but it works fine in Dos..void DEH_LoadDehackedLump(int lump){    MYFILE f;    f.size = W_LumpLength(lump);    f.data = Z_Malloc(f.size + 1, PU_STATIC, 0);    W_ReadLump(lump, f.data);    f.curpos = f.data;    f.data[f.size] = 0;    DEH_LoadDehackedFile(&f);    Z_Free(f.data);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -