summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/gokz-localdb/db/setup_map_courses.sp
blob: 69bb89e56b8e9d48157425f13106a3cc397001d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
	Inserts the map's courses into the database.
*/



void DB_SetupMapCourses()
{
	char query[512];

	Transaction txn = SQL_CreateTransaction();

	for (int course = 0; course < GOKZ_MAX_COURSES; course++)
	{
		if (!GOKZ_GetCourseRegistered(course))
		{
			continue;
		}

		switch (g_DBType)
		{
			case DatabaseType_SQLite:FormatEx(query, sizeof(query), sqlite_mapcourses_insert, gI_DBCurrentMapID, course);
			case DatabaseType_MySQL:FormatEx(query, sizeof(query), mysql_mapcourses_insert, gI_DBCurrentMapID, course);
		}
		txn.AddQuery(query);
	}

	SQL_ExecuteTransaction(gH_DB, txn, INVALID_FUNCTION, DB_TxnFailure_Generic, _, DBPrio_High);
}

void DB_SetupMapCourse(int course)
{
	char query[512];

	Transaction txn = SQL_CreateTransaction();

	switch (g_DBType)
	{
		case DatabaseType_SQLite:FormatEx(query, sizeof(query), sqlite_mapcourses_insert, gI_DBCurrentMapID, course);
		case DatabaseType_MySQL:FormatEx(query, sizeof(query), mysql_mapcourses_insert, gI_DBCurrentMapID, course);
	}
	txn.AddQuery(query);

	SQL_ExecuteTransaction(gH_DB, txn, INVALID_FUNCTION, DB_TxnFailure_Generic, _, DBPrio_High);
}