Module dpmod: Change committed
havoc at icculus.org
havoc at icculus.org
Wed Apr 9 23:22:46 EDT 2003
Commiter : havoc
CVSROOT : /cvs/cvsroot/twilight
Module : dpmod
Commit time: 2003-04-10 03:22:45 UTC
Log message:
added FRIK_FILE testing impulses
Modified files:
qc/impulse_main.qc
------=MIME.3f663e3dc5acddae281bd502705673df
Content-Type: text/plain; name="dpmod.20030410.032245.havoc.diff"
Content-Disposition: attachment; filename="dpmod.20030410.032245.havoc.diff"
Content-Transfer-Encoding: 8bit
Index: dpmod/qc/impulse_main.qc
diff -u dpmod/qc/impulse_main.qc:1.5 dpmod/qc/impulse_main.qc:1.6
--- dpmod/qc/impulse_main.qc:1.5 Tue Mar 11 14:28:59 2003
+++ dpmod/qc/impulse_main.qc Wed Apr 9 23:22:35 2003
@@ -1,4 +1,90 @@
+// FRIK_FILE extension test code
+void () saveme =
+{
+ local string h;
+ local float file;
+ file = fopen ("save.txt", FILE_WRITE);
+ fputs(file, "// Sample Save File\n");
+ h = ftos(self.health);
+ fputs(file, h);
+ fputs(file, "\n");
+ h = vtos(self.origin);
+ fputs(file, h);
+ fputs(file, "\n");
+ h = vtos(self.angles);
+ fputs(file, h);
+ fputs(file, "\n");
+ fclose(file);
+};
+
+// FRIK_FILE extension test code
+void () loadme =
+{
+ local string h;
+ local float file;
+ local vector v;
+
+ file = fopen ("save.txt", FILE_READ);
+ if (file < 0)
+ {
+ bprint("Error: file not found\n");
+ return;
+ }
+ h = fgets(file); // reads one line at a time (up to a \n)
+ // the first line is just a comment, ignore it
+ h = fgets(file);
+ self.health = stof(h);
+ h = fgets(file);
+ v = stov(h);
+ setorigin(self, v);
+ h = fgets(file);
+ v = stov(h);
+ self.angles = v;
+ self.fixangle = TRUE;
+ fclose(file);
+};
+
+// FRIK_FILE extension test code
+void() listfile =
+{
+ local float file;
+ local float i;
+ local string lineno;
+ local string line;
+
+ file = fopen ("save.txt", FILE_READ);
+ if (file < 0)
+ {
+ bprint("Error: file not found\n");
+ return;
+ }
+
+ i = 0;
+ line = fgets(file); // reads one line at a time (up to a \n)
+ while(line)
+ {
+ line = strzone(line);
+
+ i = i + 1;
+ lineno = ftos(i);
+
+ bprint(lineno);
+ bprint(": ");
+ bprint(line);
+ bprint("\n");
+
+ strunzone(line);
+
+ line = fgets(file);
+ }
+ bprint("[EOF]\n");
+
+ fclose(file);
+};
+
+
+
.float isadmin, adminnumber, admindigits, adminattempts;
void() havocbot_impulses;
@@ -271,6 +357,12 @@
if (!self.deadflag)
{
+ if (self.impulse == 40)
+ saveme();
+ if (self.impulse == 41)
+ loadme();
+ if (self.impulse == 42)
+ listfile();
if (self.impulse >= 30 && self.impulse <= 39)
{
n = 0;
More information about the twilight-commits
mailing list