]> jfr.im git - irc/gameservirc.git/commitdiff
fixed the config.cpp file back to strcpy() (oops)
authorkainazzzo <redacted>
Tue, 27 Jun 2006 01:00:06 +0000 (01:00 +0000)
committerkainazzzo <redacted>
Tue, 27 Jun 2006 01:00:06 +0000 (01:00 +0000)
added the other scripting related stuff to the gameserv.example.conf

added a directory for the scripts

git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@455 bc333340-6410-0410-a689-9d09f3c113fa

gameserv/config.cpp
gameserv/gameserv.cpp
gameserv/gameserv.example.conf
gameserv/script.cpp

index 7524f891eae48be88a709add3a805b89923eb6bf..306abbe31390ead6af8df8d5411b3fa1f5a330a5 100644 (file)
@@ -374,7 +374,7 @@ int load_config_file(char *config)
                {
                  value = strtok(NULL, " ");
                  newsdata = new char [strlen(value) + 1];
-                 strncpy(newsdata, value, sizeof(newsdata));
+                 strcpy(newsdata, value);
                  directives[21].done = true;
                }
          else if (stricmp(directive, "REFRESHPERIOD") == 0)
@@ -409,42 +409,42 @@ int load_config_file(char *config)
                {
                  value = strtok(NULL, " ");
                  nsname = new char[strlen(value) + 1];
-                 strncpy(nsname, value, sizeof(nsname));
+                 strcpy(nsname, value);
                  directives[26].done = true;
                }
          else if (stricmp(directive, "NSPASS") == 0)
                {
                  value = strtok(NULL, " ");
                  nspass = new char[strlen(value) + 1];
-                 strncpy(nspass, value, sizeof(nspass));
+                 strcpy(nspass, value);
                  directives[27].done = true;
                }
          else if (stricmp(directive, "DRAGONDATA") == 0)
                {
                  value = strtok(NULL, "");
                  dragondata = new char[strlen(value) + 1];
-                 strncpy(dragondata, value, sizeof(dragondata));
+                 strcpy(dragondata, value);
                  directives[28].done = true;
                }
          else if (stricmp(directive, "MASTERDATA") == 0)
                {
                  value = strtok(NULL, "");
                  masterdata = new char[strlen(value) + 1];
-                 strncpy(masterdata, value, sizeof(masterdata));
+                 strcpy(masterdata, value);
                  directives[29].done = true;
                }
          else if (stricmp(directive, "ITEMDATA") == 0)
                {
                  value = strtok(NULL, "");
                  itemdata = new char[strlen(value) + 1];
-                 strncpy(itemdata, value, sizeof(itemdata));
+                 strcpy(itemdata, value);
                  directives[30].done = true;
                }
          else if (stricmp(directive, "TAVERNITEMDATA") == 0)
                {
                  value = strtok(NULL, "");
                  tavernitemdata = new char[strlen(value) + 1];
-                 strncpy(tavernitemdata, value, sizeof(tavernitemdata));
+                 strcpy(tavernitemdata, value);
                  directives[31].done = true;
                }
          else if (stricmp(directive, "MAXITEMS") == 0)
@@ -457,14 +457,14 @@ int load_config_file(char *config)
                {
                  value = strtok(NULL, "");
                  storeitemdata = new char[strlen(value) + 1];
-                 strncpy(storeitemdata, value, sizeof(storeitemdata));
+                 strcpy(storeitemdata, value);
                  directives[33].done = true;
                }
          else if (stricmp(directive, "LOCALHOST") == 0)
                {
                  value = strtok(NULL, " ");
                  localhost = new char[strlen(value) + 1];
-                 strncpy(localhost, value, sizeof(localhost));
+                 strcpy(localhost, value);
                  directives[34].done = true;
                }
          else if (stricmp(directive, "ROLLOVERFORESTFIGHTS") == 0)
@@ -515,9 +515,9 @@ int load_config_file(char *config)
                }
          else if (stricmp(directive, "SCRIPTDIR") == 0)
                {
-                 value = strtok(NULL, "");
-                 scriptdir = new char [strlen(value)];
-                 strncpy(scriptdir, value, sizeof(scriptdir));
+                 value = strtok(NULL, " ");
+                 scriptdir = new char [strlen(value) + 1];
+                 strcpy(scriptdir, value);
                  directives[41].done = true;
                }
          else if (stricmp(directive, "WELCOMEMSG") == 0)
@@ -525,7 +525,7 @@ int load_config_file(char *config)
                  // This directive is optional
                  value = strtok(NULL, "");
                  welcomemsg = new char[strlen(value) + 1];
-                 strncpy(welcomemsg, value, sizeof(welcomemsg));
+                 strcpy(welcomemsg, value);
                  setWelcome();
                }
          else if (stricmp(directive, "USEPRIVMSG") == 0)
@@ -543,7 +543,7 @@ int load_config_file(char *config)
                  // This directive is optional
                  value = strtok(NULL, "");
                  ignoreserverslist = new char[strlen(value) + 1];
-                 strncpy(ignoreserverslist, value, sizeof(ignoreserverslist));
+                 strcpy(ignoreserverslist, value);
                }
          else
                {
index 1a71976c8d93e5d17cb082e3b24826588d3139ea..09c6f90911609f49d270c65df38b78a0ddbc28ed 100644 (file)
@@ -7,6 +7,7 @@
 #include "level.h"
 #include "sockhelp.h"
 #include "item.h"
+#include "script.h"
 
 #include <algorithm>
 #include <cctype>
@@ -352,6 +353,15 @@ void gameserv(char *source, char *buf)
                          notice(s_GameServ, source, "Loading monster data");
                          load_monsters();
                        }
+                 else if (stricmp(cmd2, "SCRIPTS") == 0)
+                       {
+                         // Testing scripts for now
+                         script scr;
+                         notice(s_GameServ, source, "Loading scripts");
+
+                         if (scr.loadScript("test.txt"))
+                               scr.executeScript(user->stats);
+                       }
                  else
                        {
                          display_help(source, cmd);
index 3daa80061091605c44dbce8cf8bef87cc29f6a2d..bc1c6a846479b962d3268e1659c281838e01877b 100644 (file)
@@ -95,7 +95,6 @@ SAVEDNOTICE false
 
 ########## END IRC STUFF ##########
 
-
 # Filename to store player data in.
 playerdata data/players.dat
 
@@ -114,6 +113,9 @@ masterdata data/masters.dat
 # Filename to store current dragon stats in.
 dragondata data/currentdragon.dat
 
+# Directory to look for scripts in - No trailing / necessary
+scriptdir data/scripts
+
 # This is the filename for the gameserv process ID
 # This should be different between .conf files so you have different pid
 # files saved for each process (if you want)
index 29f17f64c44336fb97339829368cca8eb9f5a5d6..91ef0f8292a670d5e4f3862e6987b442035d5fa5 100644 (file)
@@ -37,6 +37,21 @@ void script::setString(const char *str)
 
 bool script::executeScript(Player *p)
 {
+  string line;
+  string::size_type begin = 0;
+  string::size_type end = scriptstr.find("\n", 0);
+
+  while (end != string::npos)
+       {
+         // Get the line based on what we just found
+         line = scriptstr.substr(begin, end - begin);
+
+         log("Line: %s", line.c_str());
+         
+         // Find the next line
+         begin = end + 1;
+         end = scriptstr.find("\n", begin);
+       }
   return true;
 }