Skip to content

Commit 9eb7ca8

Browse files
committed
Cleaned up comments
1 parent aeb37ec commit 9eb7ca8

File tree

3 files changed

+14
-35
lines changed

3 files changed

+14
-35
lines changed

bin/win32/cod4x_mysql.dll

10.9 KB
Binary file not shown.

plugin_main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ MYSQL g_mysql[MYSQL_CONNECTION_COUNT];
2626
MYSQL_RES* g_mysql_res[MYSQL_CONNECTION_COUNT];
2727
qboolean g_mysql_reserved[MYSQL_CONNECTION_COUNT];
2828

29-
//cvar_t *g_mysql_port;
30-
3129
PCL void OnInfoRequest(pluginInfo_t *info)
3230
{
3331
char description[1024] = {'\0'};

script_functions.c

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ extern MYSQL g_mysql[MYSQL_CONNECTION_COUNT];
1515
extern MYSQL_RES* g_mysql_res[MYSQL_CONNECTION_COUNT];
1616
extern qboolean g_mysql_reserved[MYSQL_CONNECTION_COUNT];
1717

18-
//extern cvar_t *g_mysql_port;
19-
2018
/* =================================================================
2119
* Shows script runtime error with crash.
2220
* For use only inside gsc callbacks.
@@ -101,8 +99,8 @@ void Scr_MySQL_Real_Connect_f()
10199
if (argc != 4 && argc != 5)
102100
{
103101
Plugin_Scr_Error("Usage: handle = mysql_real_connect(<str host>, "
104-
"<str user>, <str passwd>, <str db>, "
105-
"[int port=3306]);");
102+
"<str user>, <str passwd>, <str db>, "
103+
"[int port=3306]);");
106104
return;
107105
}
108106

@@ -117,7 +115,7 @@ void Scr_MySQL_Real_Connect_f()
117115
if(port < 0 || port > 65535)
118116
{
119117
Plugin_Scr_ParamError(4, "Incorrect port: must be any integer "
120-
"from 0 to 65535");
118+
"from 0 to 65535");
121119
return;
122120
}
123121
}
@@ -145,24 +143,21 @@ void Scr_MySQL_Real_Connect_f()
145143
return;
146144
}
147145
}
148-
MYSQL* result = mysql_real_connect(&g_mysql[handle], host,
149-
user,
150-
pass,
151-
db,
152-
port, NULL, 0);
146+
MYSQL* result = mysql_real_connect(&g_mysql[handle], host, user, pass,
147+
db, port, NULL, 0);
153148

154149
/* We don't want to crash the server, so we have a check to return nothing to prevent that */
155150
if (result == NULL)
156151
{
157152
Scr_MySQL_Error("MySQL connect error: (%d) %s", mysql_errno(&g_mysql[handle]),
158153
mysql_error(&g_mysql[handle]));
159-
Plugin_Scr_AddUndefined(); // make sure we return undefined so GSC does not shit it's self.
160154
return;
161155
}
162156
g_mysql_reserved[handle] = qtrue;
163157

164158
/* Would you like to reconnect if connection is dropped? */
165-
qboolean reconnect = qtrue; // allows the database to reconnect on a new query etc.
159+
/* Allows the database to reconnect on a new query etc. */
160+
qboolean reconnect = qtrue;
166161

167162
/* Check to see if the mySQL server connection has dropped */
168163
mysql_options(&g_mysql[handle], MYSQL_OPT_RECONNECT, &reconnect);
@@ -363,8 +358,9 @@ void Scr_MySQL_Fetch_Row_f()
363358
int i;
364359
for(i = 0; i < col_count; ++i)
365360
{
366-
/* A little help here? I don't actually understand data representation
367-
Integer must be integer, string - string, float - float */
361+
/* A little help here? I don't actually understand data
362+
* representation. Integer must be integer, string - string,
363+
* float - float */
368364
MYSQL_FIELD *field = mysql_fetch_field(g_mysql_res[handle]);
369365
if(field == NULL)
370366
{
@@ -402,17 +398,13 @@ void Scr_MySQL_Fetch_Rows_f()
402398
unsigned int col_count = mysql_num_fields(g_mysql_res[handle]);
403399
int row = mysql_num_rows(g_mysql_res[handle]);
404400

405-
// do this no matter what.
401+
/* Do this no matter what */
406402
Plugin_Scr_MakeArray();
407403

408404
if(row != 0)
409405
{
410406
int i = 0;
411407

412-
//int keyArrayIndex[col_count]; // NO, NO and... NO
413-
//char* keyArray[col_count]; // When you do that, in this world one T-Max cries somewhere!
414-
// First answer: http://stackoverflow.com/questions/5377411/non-const-declaration-of-array
415-
416408
int* keyArrayIndex = calloc(col_count, sizeof(int));
417409
MYSQL_FIELD* field;
418410
while((field = mysql_fetch_field(g_mysql_res[handle])) != NULL)
@@ -422,26 +414,15 @@ void Scr_MySQL_Fetch_Rows_f()
422414
}
423415

424416
MYSQL_ROW rows;
425-
/*if( row == 1 ) // only one row? custom handling to only return a single dimensional array.
417+
while((rows = mysql_fetch_row(g_mysql_res[handle])) != NULL)
426418
{
427-
rows = mysql_fetch_row(g_mysql_res[handle]); // this will only give us one result.
419+
Plugin_Scr_MakeArray();
428420
for (i = 0; i < col_count; ++i) {
429421
Plugin_Scr_AddString(rows[i]);
430422
Plugin_Scr_AddArrayKey(keyArrayIndex[i]);
431423
}
424+
Plugin_Scr_AddArray();
432425
}
433-
else
434-
{*/
435-
while((rows = mysql_fetch_row(g_mysql_res[handle])) != NULL)
436-
{
437-
Plugin_Scr_MakeArray();
438-
for (i = 0; i < col_count; ++i) {
439-
Plugin_Scr_AddString(rows[i]);
440-
Plugin_Scr_AddArrayKey(keyArrayIndex[i]);
441-
}
442-
Plugin_Scr_AddArray();
443-
}
444-
//}
445426
free(keyArrayIndex);
446427
}
447428
}

0 commit comments

Comments
 (0)