forked from flaviojs/eathena-devel-FlavioJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basesq.h
1013 lines (809 loc) · 28.5 KB
/
basesq.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
#ifndef _SQL_H_
#define _SQL_H_
#include "baseio.h"
#include "basemysql.h"
#if defined(WITH_MYSQL)
#define DEVELOPING_CSQL
#ifdef DEVELOPING_CSQL
///////////////////////////////////////////////////////////////////////////////
NAMESPACE_BEGIN(sq)
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Column type.
/// TODO
enum ColType {
// Numeric
BIT,
TINYINT,
SMALLINT,
MEDIUMINT,
INT,
BIGINT,
FLOATING_POINT,
FIXED_POINT,
// Time and Date
DATE,
TIME,
DATETIME,
TIMESTAMP,
// Text and Bytes
TEXT,
BYTES,
ENUM,
BITFIELD // SET
};
///////////////////////////////////////////////////////////////////////////////
/// Reference actions (for OnDelete and OnUpdate).
enum RefAction
{
ACTION_UNDEFINED,
ACTION_RESTRICT,
ACTION_CASCADE,
ACTION_SETNULL,
ACTION_NOACTION
};
///////////////////////////////////////////////////////////////////////////////
/// The column only contains unique values (might contain several NULL values).
class Unique
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructors
Unique(void);
/// Destructor
virtual ~Unique(void);
};
///////////////////////////////////////////////////////////////////////////////
/// The column is indexed.
/// TODO multi-column indexes
class Index
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructors
Index(void);
/// Destructor
virtual ~Index(void);
};
///////////////////////////////////////////////////////////////////////////////
/// Reference.
/// TODO multi-column references
class Reference
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructors
Reference(const basics::string<> &from, const basics::string<> &to, RefAction onDel, RefAction onUp, const basics::string<> &tbl);
/// Destructor
virtual ~Reference(void);
///////////////////////////////////////////////////////////////////////////
/// Returns the action on delete
inline const RefAction& onDel(void) const;
/// Returns the action on update
inline const RefAction& onUp(void) const;
/// Returns the action on update
inline const basics::string<>& table(void) const;
private:
///////////////////////////////////////////////////////////////////////////
/// Action on delete.
const RefAction ref_onDel;
/// Action on update
const RefAction ref_onUp;
/// Target table
basics::string<> ref_tbl;
/// From columns
basics::vector< basics::string<> > ref_from;
/// To columns
basics::vector< basics::string<> > ref_to;
};
///////////////////////////////////////////////////////////////////////////////
/// Property.
/// TODO
template< typename T >
class Property : public basics::defaultcmp
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructors
Property(void); // required for a vector of properties
Property(const basics::string<>& name, const basics::string<>& value);
/// Destructor
virtual ~Property(void);
///////////////////////////////////////////////////////////////////////////
/// Name of the property
inline const basics::string<>& name(void);
/// Value of the property
inline const basics::string<>& value(void);
private:
///////////////////////////////////////////////////////////////////////////
/// Name of the property
basics::string<> prop_name;
/// Value of the property
basics::string<> prop_value;
};
///////////////////////////////////////////////////////////////////////////////
/// Identifies a primary column
class AutoIncrements
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructor
AutoIncrements(const uint32 from);
/// Destructor
virtual ~AutoIncrements(void);
///////////////////////////////////////////////////////////////////////////
/// Returns the starting index
inline const uint32 from(void) const;
private:
///////////////////////////////////////////////////////////////////////////
/// Starting index
const uint32 inc_from;
};
///////////////////////////////////////////////////////////////////////////////
/// Identifies a primary column
class Default
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructor
Default(const uint32 value);
Default(const basics::string<>& value);
/// Destructor
virtual ~Default(void);
///////////////////////////////////////////////////////////////////////////
/// Returns the starting index
inline const basics::string<>& value(void) const;
private:
///////////////////////////////////////////////////////////////////////////
/// Start of string
basics::string<> def_value;
};
///////////////////////////////////////////////////////////////////////////////
/// Identifies a primary column
class Primary
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructor
Primary(void);
/// Destructor
virtual ~Primary(void);
};
///////////////////////////////////////////////////////////////////////////////
/// Column
/// TODO
class Column : public basics::defaultcmp
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructors
Column(ColType type, const basics::string<>& name, bool null=true);
/// Destructor
virtual ~Column(void);
///////////////////////////////////////////////////////////////////////////
/// sets the default value of this column.
Column& operator<<(Primary& pri);
/// sets the default value of this column.
Column& operator<<(Default& value);
///////////////////////////////////////////////////////////////////////////
/// Returns the name of the table
inline const basics::string<>& name() const;
///////////////////////////////////////////////////////////////////////////
/// Returns the name of the table
inline ColType type() const;
/// Returns if a default value has been assigned
inline bool hasDefault() const;
/// Returns the default value
inline const basics::string<>& defaultsTo() const;
/// Returns if the column can have NULL values
inline bool null() const;
private:
///////////////////////////////////////////////////////////////////////////
/// type
ColType col_type;
/// name
basics::string<> col_name;
/// If the column can have NULL values
bool col_null;
/// if col_default has been defined
bool col_hasDefault;
/// default value
basics::string<> col_default;
};
///////////////////////////////////////////////////////////////////////////////
/// Int column.
/// TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT
/// T = { int8, uint8, int16, uint16, int32, uint32, int64, uint64 }
template < typename T = uint32 >
class IntColumn : public Column
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructors
IntColumn(const basics::string<>& name, bool null=true);
IntColumn(const basics::string<>& name, uint32 digits, bool null=true);
/// Destructor
virtual ~IntColumn();
};
///////////////////////////////////////////////////////////////////////////////
/// Text Column
class TextColumn : public Column
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructors
TextColumn(const basics::string<>& name, bool variable, bool null=true);
TextColumn(const basics::string<>& name, uint32 size, bool variable, bool null=true);
/// Destructor
virtual ~TextColumn();
};
///////////////////////////////////////////////////////////////////////////////
/// Byte Column
class ByteColumn : public Column
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructors
ByteColumn(const basics::string<>& name, bool null=true);
ByteColumn(const basics::string<>& name, uint32 size, bool null=true);
/// Destructor
virtual ~ByteColumn();
};
///////////////////////////////////////////////////////////////////////////////
/// Enum Column
class EnumColumn : public Column
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructors - add more as needed
EnumColumn(const basics::string<>& name, const basics::string<>& val1, const basics::string<>& val2, const basics::string<>& val3);
/// Destructor
virtual ~EnumColumn();
};
///////////////////////////////////////////////////////////////////////////////
/// Bit Column
class BitColumn : public Column
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructors
BitColumn(const basics::string<>& name, uint32 size, bool null=true);
/// Destructor
virtual ~BitColumn();
};
///////////////////////////////////////////////////////////////////////////////
/// Foreign Reference Column
class RefColumn : public Column, public Reference
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructors
RefColumn(const basics::string<>& name, RefAction onDel, RefAction onUp, const basics::string<>& ref_tbl);
RefColumn(const basics::string<>& name, const basics::string<>& ref_col, RefAction onDel, RefAction onUp);
RefColumn(const basics::string<>& name, const basics::string<>& ref_col, RefAction onDel, RefAction onUp, const basics::string<>& ref_tbl);
/// Destructor
virtual ~RefColumn();
///////////////////////////////////////////////////////////////////////////
/// Returns if the reference point to the table of this column
bool sameTable(void) const;
private:
///////////////////////////////////////////////////////////////////////////
// If it's a reference to the same table.
bool ref_sameTable;
};
///////////////////////////////////////////////////////////////////////////////
/// Table.
/// Collection of columns, properties,references and indexes.
class Table : public basics::defaultcmp
{
public:
Table();
Table& operator=(const Table& tbl);
public:
///////////////////////////////////////////////////////////////////////////
/// Constructor
Table(const basics::string<>& name);
Table(const basics::string<>& name, const basics::string<>& engine);
/// Destructor
virtual ~Table();
///////////////////////////////////////////////////////////////////////////
/// Returns the name of the table.
inline const basics::string<>& name() const;
///////////////////////////////////////////////////////////////////////////
/// Adds a column.
Table& operator<<(Column& col);
/// Adds an int column.
template < typename TT >
Table& operator<<(IntColumn< TT >& col);
/// Adds a text column.
Table& operator<<(TextColumn& col);
/// Adds a byte column.
Table& operator<<(ByteColumn& col);
/// Adds an enum column.
Table& operator<<(EnumColumn& col);
/// Adds a bit column.
Table& operator<<(BitColumn& col);
/// Adds a reference column.
Table& operator<<(RefColumn& col);
private:
///////////////////////////////////////////////////////////////////////////
/// name
const basics::string<> tbl_name;
/// columns
basics::vector< Column* > tbl_cols;
/// properties
basics::vector< Property< Table >* > tbl_props;
/// references
basics::vector< Reference* > tbl_refs;
/// indexes
basics::vector< Index* > tbl_idxs;
};
///////////////////////////////////////////////////////////////////////////////
/// Table copy.
class CopyTable : Table
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructors
CopyTable(const basics::string<>& name, const basics::string<>& copy_name);
CopyTable(const basics::string<>& name, const basics::string<>& copy_name, const basics::string<>& engine);
/// Destructor
virtual ~CopyTable();
///////////////////////////////////////////////////////////////////////////
/// Returns the name of the copied table
const basics::string<>& copy_name(void);
private:
///////////////////////////////////////////////////////////////////////////
/// name of the table to copy
basics::string<> tbl_copy_name;
};
///////////////////////////////////////////////////////////////////////////////
/// Database.
/// Collection of tables and properties.
/// TODO table/property access
class Database
{
public:
///////////////////////////////////////////////////////////////////////////
/// Constructor.
Database() {}
/// Destructor.
virtual ~Database() {}
///////////////////////////////////////////////////////////////////////////
/// Adds a table to the database.
Database& operator<<(Table& tbl);
/// Adds a copy of another existing table to the database.
/// Further changes made to the copy will not propagate to the original.
Database& operator<<(CopyTable& tbl);
///////////////////////////////////////////////////////////////////////////
/// Adds a column to the last table.
Database& operator<<(Column& col);
/// Adds an int column to the last table.
template < typename TT >
Database& operator<<(IntColumn< TT >& col);
/// Adds a text column to the last table.
Database& operator<<(TextColumn& col);
/// Adds a byte column to the last table.
Database& operator<<(ByteColumn& col);
/// Adds an enum column to the last table.
Database& operator<<(EnumColumn& col);
/// Adds a bit column to the last table.
Database& operator<<(BitColumn& col);
/// Adds a reference column to the last table.
Database& operator<<(RefColumn& col);
///////////////////////////////////////////////////////////////////////////
/// Adds a database property.
Database& operator<<(Property< Database >& prop);
/// Adds a property to the last table.
Database& operator<<(Property< Table >& prop);
/// Adds a property to the last column of the last table.
Database& operator<<(Property< Column >& prop);
///////////////////////////////////////////////////////////////////////////
/// Sets the last column of the last table as part of the primary key
/// The column is automatically set to NOT NULL
Database& operator<<(Primary& p);
/// Sets the default value of the colunm of the last table
Database& operator<<(Default& default_);
/// Sets the last colunm of the last table as incrementable
Database& operator<<(AutoIncrements& from);
/// Sets the last column of the last table as unique.
Database& operator<<(Unique& prop);
/// Adds an index to the last table
Database& operator<<(Index& idx);
private:
/// Returns if
bool canAddColumn(const basics::string<>& name) const;
///////////////////////////////////////////////////////////////////////////
/// tables
basics::vector< Table > db_tbls;
/// properties
basics::vector< Property< Database > > db_props;
};
///////////////////////////////////////////////////////////////////////////////
NAMESPACE_END(sq)
///////////////////////////////////////////////////////////////////////////////
#endif // DEVELOPING_CSQL
///////////////////////////////////////////////////////////////////////////////
// sql base interface.
// wrapper for the sql handle, table control and parameter storage
class CSQLParameter
{
protected:
///////////////////////////////////////////////////////////////////////////
static basics::CMySQL sqlbase; ///< sql handle and connection pool
///////////////////////////////////////////////////////////////////////////
static basics::CParam< basics::string<> > mysqldb_id; ///< username
static basics::CParam< basics::string<> > mysqldb_pw; ///< password
static basics::CParam< basics::string<> > mysqldb_db; ///< database
static basics::CParam< basics::string<> > mysqldb_ip; ///< server ip
static basics::CParam< basics::string<> > mysqldb_cp; ///< server code page
static basics::CParam< ushort > mysqldb_port; ///< server port
///////////////////////////////////////////////////////////////////////////
// parameters
static basics::CParam< basics::string<> > tbl_login_log;
static basics::CParam< basics::string<> > tbl_char_log;
static basics::CParam< basics::string<> > tbl_map_log;
static basics::CParam< basics::string<> > tbl_login_status;
static basics::CParam< basics::string<> > tbl_char_status;
static basics::CParam< basics::string<> > tbl_map_status;
static basics::CParam< basics::string<> > tbl_account;
static basics::CParam< basics::string<> > tbl_char;
static basics::CParam< basics::string<> > tbl_memo;
static basics::CParam< basics::string<> > tbl_inventory;
static basics::CParam< basics::string<> > tbl_cart;
static basics::CParam< basics::string<> > tbl_skill;
static basics::CParam< basics::string<> > tbl_friends;
static basics::CParam< basics::string<> > tbl_mail;
static basics::CParam< basics::string<> > tbl_login_reg;
static basics::CParam< basics::string<> > tbl_login_reg2;
static basics::CParam< basics::string<> > tbl_char_reg;
static basics::CParam< basics::string<> > tbl_guild_reg;
static basics::CParam< basics::string<> > tbl_guild;
static basics::CParam< basics::string<> > tbl_guild_skill;
static basics::CParam< basics::string<> > tbl_guild_member;
static basics::CParam< basics::string<> > tbl_guild_position;
static basics::CParam< basics::string<> > tbl_guild_alliance;
static basics::CParam< basics::string<> > tbl_guild_expulsion;
static basics::CParam< basics::string<> > tbl_castle;
static basics::CParam< basics::string<> > tbl_castle_guardian;
static basics::CParam< basics::string<> > tbl_party;
static basics::CParam< basics::string<> > tbl_storage;
static basics::CParam< basics::string<> > tbl_guild_storage;
static basics::CParam< basics::string<> > tbl_pet;
static basics::CParam< basics::string<> > tbl_homunculus;
static basics::CParam< basics::string<> > tbl_homunskill;
static basics::CParam< basics::string<> > tbl_variable;
static basics::CParam<bool> wipe_sql;
static basics::CParam< basics::string<> > sql_engine;
static basics::CParam<bool> log_login;
static basics::CParam<bool> log_char;
static basics::CParam<bool> log_map;
static bool ParamCallback_Database_string(const basics::string<>& name, basics::string<>& newval, const basics::string<>& oldval);
static bool ParamCallback_Database_ushort(const basics::string<>& name, ushort& newval, const ushort& oldval);
static bool ParamCallback_Tables(const basics::string<>& name, basics::string<>& newval, const basics::string<>& oldval);
///////////////////////////////////////////////////////////////////////////
/// read number of rows from given table
size_t get_table_size(basics::string<> tbl_name) const
{
basics::CMySQLConnection dbcon1(this->sqlbase);
basics::string<> query;
query << "SELECT COUNT(*) "
"FROM `" << dbcon1.escaped(tbl_name) << "` ";
if( dbcon1.ResultQuery(query) )
{
return atol( dbcon1[0] );
}
return 0;
}
///////////////////////////////////////////////////////////////////////////
/// constructor.
/// initialize the database on the first run
CSQLParameter(const char* configfile)
{
if(configfile) basics::CParamBase::loadFile(configfile);
static bool first=true;
if(first)
{
this->rebuild();
first = false;
}
}
public:
///////////////////////////////////////////////////////////////////////////
/// destructor
~CSQLParameter() {}
///////////////////////////////////////////////////////////////////////////
// rebuild the tables
static void rebuild();
};
///////////////////////////////////////////////////////////////////////////////
//
class CAccountDB_sql : public CAccountDBInterface, public CSQLParameter
{
public:
///////////////////////////////////////////////////////////////////////////
// construct/destruct
CAccountDB_sql(const char* configfile=NULL) : CSQLParameter(configfile)
{
this->init(configfile);
}
virtual ~CAccountDB_sql()
{
close();
}
protected:
///////////////////////////////////////////////////////////////////////////
bool init(const char* configfile);
bool close();
bool sql2struct(const basics::string<>& querycondition, CLoginAccount& account);
public:
///////////////////////////////////////////////////////////////////////////
// functions for db interface
virtual size_t size() const;
virtual CLoginAccount& operator[](size_t i);
virtual bool existAccount(const char* userid);
virtual bool searchAccount(const char* userid, CLoginAccount&account);
virtual bool searchAccount(uint32 accid, CLoginAccount&account);
virtual bool insertAccount(const char* userid, const char* passwd, unsigned char sex, const char* email, CLoginAccount&account);
virtual bool removeAccount(uint32 accid);
virtual bool saveAccount(const CLoginAccount& account);
};
class CCharDB_sql : public CCharDBInterface, public CSQLParameter
{
public:
CCharDB_sql(const char *dbcfgfile) : CSQLParameter(dbcfgfile)
{
init(dbcfgfile);
}
virtual ~CCharDB_sql()
{}
protected:
///////////////////////////////////////////////////////////////////////////
// normal function
bool init(const char* configfile);
bool close(){ return true; }
public:
///////////////////////////////////////////////////////////////////////////
// access interface
virtual size_t size() const;
virtual CCharCharacter& operator[](size_t i);
virtual bool existChar(const char* name);
virtual bool existChar(uint32 char_id);
virtual bool searchChar(const char* name, CCharCharacter&data);
virtual bool searchChar(uint32 char_id, CCharCharacter&data);
virtual bool insertChar(CCharAccount &account, const char *name, unsigned char str, unsigned char agi, unsigned char vit, unsigned char int_, unsigned char dex, unsigned char luk, unsigned char slot, unsigned char hair_style, unsigned char hair_color, CCharCharacter&data);
virtual bool removeChar(uint32 charid);
virtual bool saveChar(const CCharCharacter& data);
virtual bool searchAccount(uint32 accid, CCharCharAccount& account);
virtual bool saveAccount(CCharAccount& account);
virtual bool removeAccount(uint32 accid);
virtual size_t getMailCount(uint32 cid, uint32 &all, uint32 &unread);
virtual size_t listMail(uint32 cid, unsigned char box, unsigned char *buffer);
virtual bool readMail(uint32 cid, uint32 mid, CMail& mail);
virtual bool deleteMail(uint32 cid, uint32 mid);
virtual bool sendMail(uint32 senderid, const char* sendername, const char* targetname, const char *head, const char *body, uint32 zeny, const struct item& item, uint32& msgid, uint32& tid);
virtual void loadfamelist();
};
///////////////////////////////////////////////////////////////////////////////
//
class CGuildDB_sql : public CGuildDBInterface, public CSQLParameter
{
public:
///////////////////////////////////////////////////////////////////////////
// construct/destruct
CGuildDB_sql(const char *dbcfgfile) : CSQLParameter(dbcfgfile)
{
this->init(dbcfgfile);
}
virtual ~CGuildDB_sql()
{
close();
}
private:
///////////////////////////////////////////////////////////////////////////
// normal function
bool init(const char* configfile);
bool close()
{
return true;
}
public:
///////////////////////////////////////////////////////////////////////////
// access interface
virtual size_t size() const;
virtual CGuild& operator[](size_t i);
virtual size_t castlesize() const;
virtual CCastle &castle(size_t i);
virtual bool searchGuild(const char* name, CGuild& guild);
virtual bool searchGuild(uint32 guildid, CGuild& guild); // TODO: Write
virtual bool insertGuild(const struct guild_member &member, const char *name, CGuild &g);
virtual bool removeGuild(uint32 guild_id);
virtual bool saveGuild(const CGuild& g);
virtual bool searchCastle(ushort castleid, CCastle& castle);
virtual bool saveCastle(const CCastle& castle);
virtual bool removeCastle(ushort castle_id);
virtual bool getCastles(basics::vector<CCastle>& castlevector);
virtual uint32 has_conflict(uint32 guild_id, uint32 account_id, uint32 char_id);
};
///////////////////////////////////////////////////////////////////////////////
//
class CPartyDB_sql : public CPartyDBInterface, public CSQLParameter
{
public:
///////////////////////////////////////////////////////////////////////////
// construct/destruct
CPartyDB_sql(const char *dbcfgfile) : CSQLParameter(dbcfgfile)
{
init(dbcfgfile);
}
virtual ~CPartyDB_sql()
{
close();
}
private:
///////////////////////////////////////////////////////////////////////////
// normal function
bool init(const char* configfile);
bool close()
{
return true;
}
///////////////////////////////////////////////////////////////////////////
// access interface
virtual size_t size() const;
virtual CParty& operator[](size_t i);
virtual bool searchParty(const char* name, CParty& p);
virtual bool searchParty(uint32 pid, CParty& p);
virtual bool insertParty(uint32 accid, const char* nick, const char* mapname, ushort lv, const char* name, CParty& p);
virtual bool removeParty(uint32 pid);
virtual bool saveParty(const CParty& p);
};
///////////////////////////////////////////////////////////////////////////////
// Storage Database Interface
class CPCStorageDB_sql : public CPCStorageDBInterface, public CSQLParameter
{
public:
///////////////////////////////////////////////////////////////////////////
// construct/destruct
CPCStorageDB_sql(const char *dbcfgfile) : CSQLParameter(dbcfgfile)
{
init(dbcfgfile);
}
~CPCStorageDB_sql()
{
close();
}
///////////////////////////////////////////////////////////////////////////
// normal function
bool init(const char* configfile);
bool close()
{
return true;
}
///////////////////////////////////////////////////////////////////////////
// access interface
size_t size() const;
CPCStorage& operator[](size_t i);
virtual bool searchStorage(uint32 accid, CPCStorage& stor);
virtual bool removeStorage(uint32 accid);
virtual bool saveStorage(const CPCStorage& stor);
};
///////////////////////////////////////////////////////////////////////////////
//
class CGuildStorageDB_sql : public CGuildStorageDBInterface, public CSQLParameter
{
public:
///////////////////////////////////////////////////////////////////////////
// construct/destruct
CGuildStorageDB_sql(const char *dbcfgfile) : CSQLParameter(dbcfgfile)
{
init(dbcfgfile);
};
virtual ~CGuildStorageDB_sql()
{
close();
}
///////////////////////////////////////////////////////////////////////////
// access interface
size_t size() const;
CGuildStorage& operator[](size_t i);
virtual bool searchStorage(uint32 gid, CGuildStorage& stor);
virtual bool removeStorage(uint32 gid);
virtual bool saveStorage(const CGuildStorage& stor);
private:
///////////////////////////////////////////////////////////////////////////
// normal function
bool init(const char* configfile);
bool close()
{
return true;
}
};
///////////////////////////////////////////////////////////////////////////////
// Pet Database Interface
class CPetDB_sql : public CPetDBInterface, public CSQLParameter
{
public:
CPetDB_sql(const char *dbcfgfile) : CSQLParameter(dbcfgfile)
{
init(dbcfgfile);
}
virtual ~CPetDB_sql()
{
close();
}
protected:
bool init(const char *dbcfgfile);
bool close()
{
return true;
}
public:
virtual size_t size() const;
virtual CPet& operator[](size_t i);
virtual bool searchPet(uint32 pid, CPet& pet);
virtual bool insertPet(uint32 accid, uint32 cid, short pet_class, short pet_lv, short pet_egg_id, ushort pet_equip, short intimate, short hungry, char renameflag, char incuvat, char *pet_name, CPet& pet);
virtual bool removePet(uint32 pid);
virtual bool savePet(const CPet& pet);
};
///////////////////////////////////////////////////////////////////////////////
// Homunculi Database Interface
class CHomunculusDB_sql : public CHomunculusDBInterface, public CSQLParameter
{
public:
CHomunculusDB_sql(const char *dbcfgfile) : CSQLParameter(dbcfgfile)
{
init(dbcfgfile);
}
virtual ~CHomunculusDB_sql()
{
close();
}
protected:
bool init(const char *dbcfgfile);
bool close()
{
return true;
}
public:
virtual size_t size() const;
virtual CHomunculus& operator[](size_t i);
virtual bool searchHomunculus(uint32 hid, CHomunculus& hom);
virtual bool insertHomunculus(CHomunculus& hom);
virtual bool removeHomunculus(uint32 hid);
virtual bool saveHomunculus(const CHomunculus& hom);
};
///////////////////////////////////////////////////////////////////////////////
// Variable Database Interface
// testcase, possibly seperate into different implementations
class CVarDB_sql : public CVarDBInterface, public CSQLParameter
{
public:
CVarDB_sql(const char *dbcfgfile) : CSQLParameter(dbcfgfile)
{
init(dbcfgfile);
}
virtual ~CVarDB_sql()
{
close();
}
protected:
bool init(const char *dbcfgfile);
bool close()
{
return true;
}
public:
///////////////////////////////////////////////////////////////////////////
// access interface
virtual size_t size() const;