[ScryMUD] SVN Commit Info r743 - trunk/mud/grrmud/server

scrymud at wanfear.com scrymud at wanfear.com
Fri Dec 10 04:59:26 PST 2004


Author: eroper
Date: 2004-12-10 04:59:25 -0800 (Fri, 10 Dec 2004)
New Revision: 743

Modified:
   trunk/mud/grrmud/server/critter.cc
   trunk/mud/grrmud/server/critter.h
   trunk/mud/grrmud/server/login.cc
Log:
critter format version information now stored in any file a critter is stored
in.


Modified: trunk/mud/grrmud/server/critter.cc
===================================================================
--- trunk/mud/grrmud/server/critter.cc	2004-12-10 09:19:39 UTC (rev 742)
+++ trunk/mud/grrmud/server/critter.cc	2004-12-10 12:59:25 UTC (rev 743)
@@ -1183,7 +1183,7 @@
 }
 
 
-void mob_data::Read(ifstream& ofile, short read_all) {
+void mob_data::Read(ifstream& ofile, short read_all, int format_version) {
    char tmp[81];
    
    Clear();
@@ -1588,12 +1588,11 @@
    }//for
    ofile << "-1 \twanted in\n";
    
-   ofile << endl;
    ofile << "*** end of pc data ***\n";
 }//Write()       
 
 
-void pc_data::Read(ifstream& ofile) {
+void pc_data::Read(ifstream& ofile, int format_version) {
    int i;
    char tmp[81];
    
@@ -1714,13 +1713,15 @@
       ofile.getline(tmp, 80);
    }
 
-   // Read in wanted_in information
-   ofile >> i;
-   while (i != -1) {
-      wanted_in[i] = 1;
+   if ( format_version > 0 ) {
+      // Read in wanted_in information
       ofile >> i;
+      while (i != -1) {
+         wanted_in[i] = 1;
+         ofile >> i;
+      }
+      ofile.getline(tmp, 80);
    }
-   ofile.getline(tmp, 80);
 
    ofile.getline(tmp, 80); //grabs extra line/comment
 }//Read()       
@@ -2447,6 +2448,8 @@
    String* st_ptr;
    String tmp_str(100);
 
+   ofile << "%" << CRITTER_FORMAT_VERSION << "\tcritter format version" << endl;
+
    int len = 0;
    while ((st_ptr = st_cell.next())) {
       len += st_ptr->Strlen();
@@ -3433,6 +3436,7 @@
    char tmp[81];
    String tmp_str(80);
    String* string;
+   int format_version;
 
    Clear();
 
@@ -3443,6 +3447,20 @@
       return;
    }
 
+   // look for a file-version identifier
+   {
+      char tst_char;
+      ofile.get(tst_char);
+      if ( tst_char != '%' ) {
+         // no file version 
+         ofile.putback(tst_char);
+         format_version = 0;
+      } else {
+         ofile >> format_version;
+         ofile.getline(tmp, 80);
+      }
+   }
+
    test = TRUE;
    while (test) {
       if (!ofile) {
@@ -3548,7 +3566,9 @@
       ss_ptr = new stat_spell_cell;
       ss_ptr->stat_spell = i;
       ofile >> ss_ptr->bonus_duration;
-      ofile >> ss_ptr->bonus_value;
+      if ( format_version > 0 ) {
+         ofile >> ss_ptr->bonus_value;
+      }
 
       Put(ss_ptr, affected_by);
       ofile >> i;
@@ -3600,13 +3620,14 @@
       if (!(pc)) {
          pc = new pc_data;
       }//if
-      pc->Read(ofile);  
+      pc->Read(ofile, format_version);  
+      pc->file_format_version = format_version;
    }//if
    else { //its a mob
       if (!(mob)) {
          mob = new mob_data;
       }//if
-      mob->Read(ofile, read_all); 
+      mob->Read(ofile, read_all, format_version); 
    }//else
    ofile.getline(tmp, 80);      
    //mudlog.log(DBG, "Done w/read crit.\n");

Modified: trunk/mud/grrmud/server/critter.h
===================================================================
--- trunk/mud/grrmud/server/critter.h	2004-12-10 09:19:39 UTC (rev 742)
+++ trunk/mud/grrmud/server/critter.h	2004-12-10 12:59:25 UTC (rev 743)
@@ -28,6 +28,8 @@
 #ifndef GRRMUD_CRITTER_INCLUDE_H
 #define GRRMUD_CRITTER_INCLUDE_H
 
+#define CRITTER_FORMAT_VERSION 1
+
 #include <bitfield.h>
 #include <string2.h>
 #include "classes.h"
@@ -519,7 +521,7 @@
    void Clear();
    mob_data& operator= (mob_data& source);
    void Write(ofstream& ofile);
-   void Read(ifstream& ofile, short read_all);
+   void Read(ifstream& ofile, short read_all, int format_version);
    int isInProcNow() { return (cur_script && (cur_script->isInProgress())); }
    void addProcScript(const String& txt, MobScript* script_data);
    void finishedMobProc();
@@ -554,6 +556,7 @@
    String last_input;
    String rep_to;
    int descriptor;    //socket descriptor
+   int file_format_version; //used for login sanity
 
    // When modifying this, modify PC_DATA_FLAGS_NAMES in const.cc
    bitfield pc_data_flags;
@@ -635,7 +638,7 @@
 
    void Clear();
    void Write(ofstream& ofile);
-   void Read(ifstream& ofile);
+   void Read(ifstream& ofile, int format_version);
    static int getInstanceCount() { return _cnt; }
 
    int client;

Modified: trunk/mud/grrmud/server/login.cc
===================================================================
--- trunk/mud/grrmud/server/login.cc	2004-12-10 09:19:39 UTC (rev 742)
+++ trunk/mud/grrmud/server/login.cc	2004-12-10 12:59:25 UTC (rev 743)
@@ -417,7 +417,7 @@
                }
 
                // re-gain effects from worn gear
-               {
+               if ( pc->file_format_version > 0 ) {
                   int i;
                   for(i=0;i<MAX_EQ;i++) {
                      if (EQ[i]) {




More information about the ScryMUD mailing list