Skip to content

Commit 75ce7c1

Browse files
committed
Generate sql code in header file
1 parent 04b52ab commit 75ce7c1

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

lib/controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def include_path_abs
6262
"#{CONTROLLER_BASE_DIR_INCLUDE}/#{@path.join('/')}/#{header_filename}"
6363
end
6464

65+
def include_sql_path_abs
66+
"#{CONTROLLER_BASE_DIR_INCLUDE}/#{@path.join('/')}/sql_columns.h"
67+
end
68+
6569
def self.base_pvp
6670
return @base_pvp_controller if @base_pvp_controller
6771

lib/gamemode.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def gen_cpp_header
5353
'',
5454
"#include <#{@parent_controller.include_path_abs}>",
5555
'',
56+
header_sql,
57+
'',
5658
"class #{@controller.class_name} : public #{@parent_controller.class_name}",
5759
'{',
5860
'public:',
@@ -161,4 +163,15 @@ def header_methods
161163
'int OnCharacterDeath(class CCharacter *pVictim, CPlayer *pKiller, int Weapon) override;'
162164
].map { |m| "\t#{m}" }.join("\n")
163165
end
166+
167+
def header_sql
168+
[
169+
'// uncomment the lines below if you bring your own sql_columns.h file',
170+
'// this is optional and only needed if your gamemode needs additional',
171+
'// columns in the sql database.',
172+
"// #define SQL_COLUMN_FILE <#{@controller.include_sql_path_abs}>",
173+
"// #define SQL_COLUMN_CLASS C#{@controller.name}Columns",
174+
'// #include <game/server/instagib/column_template.h>',
175+
].join("\n")
176+
end
164177
end

0 commit comments

Comments
 (0)