r3178 - in trunk/data/qcsrc: common menu-div0test server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Jan 18 20:47:28 EST 2008


Author: div0
Date: 2008-01-18 20:47:28 -0500 (Fri, 18 Jan 2008)
New Revision: 3178

Modified:
   trunk/data/qcsrc/common/util.qc
   trunk/data/qcsrc/menu-div0test/todo
   trunk/data/qcsrc/server/extensions.qh
Log:
ifdeffed out database support


Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc	2008-01-18 23:23:53 UTC (rev 3177)
+++ trunk/data/qcsrc/common/util.qc	2008-01-19 01:47:28 UTC (rev 3178)
@@ -233,3 +233,71 @@
 	strunzone(s);
 	return sc;
 }
+
+#if 0
+#define DB_BUCKETS 16384
+void db_save(float db, string filename)
+{
+	float fh, i;
+	fh = fopen(filename, FILE_WRITE);
+	if(fh < 0)
+		error(strcat("Can't write DB to ", filename));
+	for(i = 0; i < DB_BUCKETS; ++i)
+		fputs(fh, strcat(bufstr_get(db, i), "\n"));
+	fclose(fh);
+}
+
+float db_load(string filename)
+{
+	float db, fh, i;
+	string l;
+	db = buf_create();
+	if(db < 0)
+		return -1;
+	fh = fopen(filename, FILE_READ);
+	if(fh < 0)
+		return db;
+	while((l = fgets(fh)))
+	{
+		if(l != "")
+			bufstr_set(db, i, l);
+		++i;
+	}
+	fclose(fh);
+	return db;
+}
+
+void db_close(float db)
+{
+	buf_del(db);
+}
+
+string db_get(float db, string key)
+{
+	float h;
+	h = hash(FALSE, key);
+	return infoget(bufstr_get(db, h), key);
+}
+
+void db_put(float db, string key, string value)
+{
+	float h;
+	h = hash(FALSE, key);
+	bufstr_set(db, h, infoadd(bufstr_get(db, h), key, value));
+}
+
+void db_test()
+{
+	float db, i;
+	print("LOAD...\n");
+	db = db_load("foo.db");
+	print("LOADED. FILL...\n");
+	for(i = 0; i < DB_BUCKETS; ++i)
+		db_put(db, ftos(random()), "X");
+	print("FILLED. SAVE...\n");
+	db_save(db, "foo.db");
+	print("SAVED. CLOSE...\n");
+	db_close(db);
+	print("CLOSED.\n");
+}
+#endif

Modified: trunk/data/qcsrc/menu-div0test/todo
===================================================================
--- trunk/data/qcsrc/menu-div0test/todo	2008-01-18 23:23:53 UTC (rev 3177)
+++ trunk/data/qcsrc/menu-div0test/todo	2008-01-19 01:47:28 UTC (rev 3178)
@@ -1,5 +1 @@
-TODO singleplayer dialog
-	TODO campaign
-	TODO instant action
 TODO credits dialog
-TODO update notification

Modified: trunk/data/qcsrc/server/extensions.qh
===================================================================
--- trunk/data/qcsrc/server/extensions.qh	2008-01-18 23:23:53 UTC (rev 3177)
+++ trunk/data/qcsrc/server/extensions.qh	2008-01-19 01:47:28 UTC (rev 3178)
@@ -1538,3 +1538,16 @@
 float(string s1, string s2, float len) strncmp = #228;
 float(string s1, string s2) strcasecmp = #229;
 float(string s1, string s2, float len) strncasecmp = #230;
+
+//DP_QC_STRINGBUFFERS
+float() buf_create = #460;
+void(float bufhandle) buf_del = #461;
+float(float bufhandle) buf_getsize = #462;
+void(float bufhandle_from, float bufhandle_to) buf_copy = #463;
+void(float bufhandle, float sortpower, float backward) buf_sort = #464;
+string(float bufhandle, string glue) buf_implode = #465;
+string(float bufhandle, float string_index) bufstr_get = #466;
+void(float bufhandle, float string_index, string str) bufstr_set = #467;
+float(float bufhandle, string str, float order) bufstr_add = #468;
+void(float bufhandle, float string_index) bufstr_free = #469;
+float(float caseinsensitive, string s, ...) hash = #487;




More information about the nexuiz-commits mailing list