Initial MSVC 2008 projects workspace

This commit is contained in:
alexey.min
2012-02-01 05:25:08 +00:00
commit 03de3bdc95
1446 changed files with 476853 additions and 0 deletions

207
l2packets/l2data/L2Data.cpp Normal file
View File

@@ -0,0 +1,207 @@
#include "stdafx.h"
#include "L2Data.h"
// Lineage II races
char *L2Race[L2MaxRaces];
// Lineage II classes
char *L2Class[L2MaxClasses];
// Sex :)
char *L2Sex[L2MaxSexes];
// Races pictures depending on sex
// L2MaxRacePics = L2MaxRaces * L2MaxSexes;
char *L2RacePic[L2MaxRacePics];
// NPC races/classes
// index is level of skill id = 4416
char *L2NPCRace[L2MaxNPCRaces];
void L2Data_init()
{
// (char *) conversion because gcc4 thinks that string constants like "Human" are (const char *)
// but really all these strings are used like (const char *) pointers, so it must be OK
L2Race[0] = (char *)"Human";
L2Race[1] = (char *)"Elf";
L2Race[2] = (char *)"Dark Elf";
L2Race[3] = (char *)"Orc";
L2Race[4] = (char *)"Dwarf";
L2Race[5] = (char *)"Kamael";
memset( L2Class, 0, sizeof(L2Class) );
L2Class[0] = (char *)"Human Fighter";
L2Class[1] = (char *)"Warrior";
L2Class[2] = (char *)"Gladiator";
L2Class[3] = (char *)"Warlord";
L2Class[4] = (char *)"Knight";
L2Class[5] = (char *)"Paladin";
L2Class[6] = (char *)"Dark Avenger";
L2Class[7] = (char *)"Rogue";
L2Class[8] = (char *)"Treasure Hunter";
L2Class[9] = (char *)"Hawkeye";
L2Class[10] = (char *)"Human Mystic";
L2Class[11] = (char *)"Human Wizard";
L2Class[12] = (char *)"Sorceror";
L2Class[13] = (char *)"Necromancer";
L2Class[14] = (char *)"Warlock";
L2Class[15] = (char *)"Cleric";
L2Class[16] = (char *)"Bishop";
L2Class[17] = (char *)"Prophet";
L2Class[18] = (char *)"Elven Fighter";
L2Class[19] = (char *)"Elven Knight";
L2Class[20] = (char *)"Temple Knight";
L2Class[21] = (char *)"Sword Singer";
L2Class[22] = (char *)"Elven Scout";
L2Class[23] = (char *)"Plains Walker";
L2Class[24] = (char *)"Silver Ranger";
L2Class[25] = (char *)"Elven Mystic";
L2Class[26] = (char *)"Elven Wizard";
L2Class[27] = (char *)"SpellSinger";
L2Class[28] = (char *)"Elemental Summoner";
L2Class[29] = (char *)"Elven Oracle";
L2Class[30] = (char *)"Elven Elder";
L2Class[31] = (char *)"Dark Fighter";
L2Class[32] = (char *)"Paulus Knight";
L2Class[33] = (char *)"Shillien Knight";
L2Class[34] = (char *)"BladeDancer";
L2Class[35] = (char *)"Assassin";
L2Class[36] = (char *)"Abyss Walker";
L2Class[37] = (char *)"Phantom Ranger";
L2Class[38] = (char *)"Dark Mystic";
L2Class[39] = (char *)"Dark Wizard";
L2Class[40] = (char *)"Spellhowler";
L2Class[41] = (char *)"Phantom Summoner";
L2Class[42] = (char *)"Shillien Oracle";
L2Class[43] = (char *)"Shillien Elder";
L2Class[44] = (char *)"Orc Fighter";
L2Class[45] = (char *)"Orc Raider";
L2Class[46] = (char *)"Destroyer";
L2Class[47] = (char *)"Orc Monk";
L2Class[48] = (char *)"Tyrant";
L2Class[49] = (char *)"Orc Mystic";
L2Class[50] = (char *)"Orc Shaman";
L2Class[51] = (char *)"Overlord";
L2Class[52] = (char *)"Warcryer";
L2Class[53] = (char *)"Dwarven Fighter";
L2Class[54] = (char *)"Scavenger";
L2Class[55] = (char *)"Bounty Hunter";
L2Class[56] = (char *)"Artisan";
L2Class[57] = (char *)"Warsmith";
//
// indexes [ 58 .. 87 ] unused
//
L2Class[88] = (char *)"Duelist";
L2Class[89] = (char *)"Dreadnought";
L2Class[90] = (char *)"Phoenix Knight";
L2Class[91] = (char *)"HellKnight";
L2Class[92] = (char *)"Sagittarius";
L2Class[93] = (char *)"Adventurer";
L2Class[94] = (char *)"Archmage";
L2Class[95] = (char *)"Soultaker";
L2Class[96] = (char *)"Arcana Lord";
L2Class[97] = (char *)"Cardinal";
L2Class[98] = (char *)"Hierophant";
L2Class[99] = (char *)"Eva's Templar";
L2Class[100] = (char *)"Sword Muse";
L2Class[101] = (char *)"Wind Rider";
L2Class[102] = (char *)"Moonlight Sentinel";
L2Class[103] = (char *)"Mystic Muse";
L2Class[104] = (char *)"Elemental Master";
L2Class[105] = (char *)"Eva's Saint";
L2Class[106] = (char *)"Shillien Templar";
L2Class[107] = (char *)"Spectral Dancer";
L2Class[108] = (char *)"Ghost Hunter";
L2Class[109] = (char *)"Ghost Sentinel";
L2Class[110] = (char *)"Storm Screamer";
L2Class[111] = (char *)"Spectral Master";
L2Class[112] = (char *)"Shillien Saint";
L2Class[113] = (char *)"Titan";
L2Class[114] = (char *)"Grand Khauatari";
L2Class[115] = (char *)"Dominator";
L2Class[116] = (char *)"Doomcryer";
L2Class[117] = (char *)"Fortune Seeker";
L2Class[118] = (char *)"Maestro";
//
// indexes [ 119 .. 122 ] unused
//
L2Class[123] = (char *)"Kamael Male Soldier";
L2Class[124] = (char *)"Kamael Female Soldier";
L2Class[125] = (char *)"Trooper";
L2Class[126] = (char *)"Warder";
L2Class[127] = (char *)"Berserker";
L2Class[128] = (char *)"Soulbreaker (Male)"; //"Male Soulbreaker";
L2Class[129] = (char *)"Soulbreaker (Female)"; //"Female Soulbreaker";
L2Class[130] = (char *)"Arbalester";
L2Class[131] = (char *)"Doombringer";
L2Class[132] = (char *)"Soulhound (Male)"; // male
L2Class[133] = (char *)"Soulhound (Female)"; // female
L2Class[134] = (char *)"Trickster"; // female
L2Class[135] = (char *)"Inspector";
L2Class[136] = (char *)"Judicator";
L2Sex[0] = (char *)"Male";
L2Sex[1] = (char *)"Female";
L2RacePic[0] = (char *)"human_male";
L2RacePic[1] = (char *)"human_female";
L2RacePic[2] = (char *)"elf_male";
L2RacePic[3] = (char *)"elf_female";
L2RacePic[4] = (char *)"darkelf_male";
L2RacePic[5] = (char *)"darkelf_female";
L2RacePic[6] = (char *)"orc_male";
L2RacePic[7] = (char *)"orc_female";
L2RacePic[8] = (char *)"dwarf_male";
L2RacePic[9] = (char *)"dwarf_female";
L2RacePic[10] = (char *)"kamael_male";
L2RacePic[11] = (char *)"kamael_female";
L2NPCRace[0] = (char *)"NPC race index 0 not used";
L2NPCRace[1] = (char *)"Undead";
L2NPCRace[2] = (char *)"Magic Creatures";
L2NPCRace[3] = (char *)"Beasts";
L2NPCRace[4] = (char *)"Animals";
L2NPCRace[5] = (char *)"Plants";
L2NPCRace[6] = (char *)"Humanoids";
L2NPCRace[7] = (char *)"Spirits";
L2NPCRace[8] = (char *)"Angels";
L2NPCRace[9] = (char *)"Demons";
L2NPCRace[10] = (char *)"Dragons";
L2NPCRace[11] = (char *)"Giants";
L2NPCRace[12] = (char *)"Bugs";
L2NPCRace[13] = (char *)"Fairies";
L2NPCRace[14] = (char *)"Humans";
L2NPCRace[15] = (char *)"Elves";
L2NPCRace[16] = (char *)"Dark Elves";
L2NPCRace[17] = (char *)"Orcs";
L2NPCRace[18] = (char *)"Dwarves";
L2NPCRace[19] = (char *)"Others";
L2NPCRace[20] = (char *)"Non-living Beings";
L2NPCRace[21] = (char *)"Siege Weapons";
L2NPCRace[22] = (char *)"Defending Army";
L2NPCRace[23] = (char *)"Mercenaries";
L2NPCRace[24] = (char *)"Unknown Creature";
}
const char *L2Data_getRace( int raceID )
{
if( (raceID<0) || (raceID>=L2MaxRaces) ) return NULL;
return L2Race[raceID];
}
const char *L2Data_getClass( int classID )
{
if( (classID<0) || (classID>=L2MaxClasses) ) return NULL;
return L2Class[classID];
}
const char *L2Data_getSex( int sexID )
{
if( (sexID<0) || (sexID>=L2MaxSexes) ) return NULL;
return L2Sex[sexID];
}
const char *L2Data_getRacePic( int raceID, int sexID )
{
int picID = raceID*2 + sexID;
if( (picID<0) || (picID>=L2MaxRacePics) ) return NULL;
return L2RacePic[picID];
}
const char *L2Data_getNPCRace( int npcRaceID )
{
if( (npcRaceID<0) || (npcRaceID>=L2MaxNPCRaces) ) return NULL;
return L2NPCRace[npcRaceID];
}

51
l2packets/l2data/L2Data.h Normal file
View File

@@ -0,0 +1,51 @@
#ifndef L2DATA_H_
#define L2DATA_H_
#include "L2Data_Recipes.h"
#define L2MaxRaces 6
#define L2MaxClasses 137
#define L2MaxSexes 2
#define L2MaxRacePics 12
#define L2MaxNPCRaces 25
void L2Data_init();
const char *L2Data_getRace( int raceID );
const char *L2Data_getClass( int classID );
const char *L2Data_getSex( int sexID );
const char *L2Data_getRacePic( int raceID, int sexID );
const char *L2Data_getNPCRace( int npcRaceID );
void L2Data_SM_init();
void L2Data_SM_free();
const char *L2Data_SM_get( unsigned int systemMessageID );
bool L2Data_DB_Init( char *outErrMsg,
const char *items_db_filename,
const char *mobs_db_filename,
const char *skills_db_filename );
void L2Data_DB_Free();
// title can be NULL
bool L2Data_DB_GetNPCNameTitleByID( unsigned int npcID, char *name, char *title );
// pic can be NULL
bool L2Data_DB_GetItemNamePicByID( unsigned int itemID, char *name, char *pic );
bool L2Data_DB_GetSkillNameByID( unsigned int skillID, char *name );
typedef struct st_L2Data_DB_Result
{
int rowCount; // row count in result set
int colCount; // columns count in result set
char ***rows; // row data: row[0] is 1st row; row[0][0] is 1st column; row[0][0][0] is 1st char in string
// input parameter
int inMaxRowsToGet; // queries do not change this parameter.
} L2Data_DB_Result, *PL2Data_DB_Result;
void L2Data_DB_Free_Result( L2Data_DB_Result *pResult );
bool L2Data_DB_Query_NPCs_ByName( const char *request, L2Data_DB_Result *pResult );
bool L2Data_DB_Query_Items_ByName( const char *request, L2Data_DB_Result *pResult );
bool L2Data_DB_Query_Skills_ByName( const char *request, L2Data_DB_Result *pResult );
#endif /* L2DATA_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
#ifndef H_RECIPEDATA
#define H_RECIPEDATA
class L2Data_RecipeInfo
{
public:
L2Data_RecipeInfo() { name[0] = 0; itemID = rec_itemID = 0; level = resultCount = mpCost = successRate; }
public:
char name[128];
unsigned int itemID;
unsigned int rec_itemID;
int level;
int resultCount;
int mpCost;
int successRate;
};
#define MAX_RECIPE_ID 910
void L2Data_InitRecipes();
bool L2Data_GetRecipeInfoForRecID( int recID, L2Data_RecipeInfo *pInfo );
#endif

View File

@@ -0,0 +1,377 @@
#include "stdafx.h"
#include "L2Data.h"
#include "sqlite3.h"
//char l2data_db_filename
int l2data_sqlite3_was_init = 0;
sqlite3 *l2data_sqlite3_conn_items = NULL;
sqlite3 *l2data_sqlite3_conn_npcs = NULL;
sqlite3 *l2data_sqlite3_conn_skills = NULL;
// synchronisation
#ifdef L2PACKETS_WINDOWS
CRITICAL_SECTION l2data_db_cs;
#endif
bool L2Data_DB_Init( char *outErrMsg,
const char *items_db_filename,
const char *mobs_db_filename,
const char *skills_db_filename )
{
if( outErrMsg ) outErrMsg[0] = 0;
if( !l2data_sqlite3_was_init )
{
// test for threadsafe
if( sqlite3_threadsafe() == 0 )
{
fprintf( stderr, "WARNING: sqlite3 is not configured to use thread-safe operations!\n" );
if( outErrMsg ) strcat( outErrMsg, "sqlite3 is not configured threadsafe! " );
}
//
int r = 0;
const char *errmsg = NULL;
// items
r = sqlite3_open( items_db_filename, &l2data_sqlite3_conn_items );
if( r != SQLITE_OK )
{
errmsg = sqlite3_errmsg( l2data_sqlite3_conn_items );
if( outErrMsg && errmsg ) strcat( outErrMsg, errmsg );
sqlite3_close( l2data_sqlite3_conn_items );
l2data_sqlite3_conn_items = NULL;
return false;
}
// npcs
r = sqlite3_open( mobs_db_filename, &l2data_sqlite3_conn_npcs );
if( r != SQLITE_OK )
{
errmsg = sqlite3_errmsg( l2data_sqlite3_conn_npcs );
if( outErrMsg && errmsg ) strcat( outErrMsg, errmsg );
sqlite3_close( l2data_sqlite3_conn_items );
l2data_sqlite3_conn_items = NULL;
sqlite3_close( l2data_sqlite3_conn_npcs );
l2data_sqlite3_conn_npcs = NULL;
return false;
}
// skills
r = sqlite3_open( skills_db_filename, &l2data_sqlite3_conn_skills );
if( r != SQLITE_OK )
{
errmsg = sqlite3_errmsg( l2data_sqlite3_conn_skills );
if( outErrMsg && errmsg ) strcat( outErrMsg, errmsg );
sqlite3_close( l2data_sqlite3_conn_items );
l2data_sqlite3_conn_items = NULL;
sqlite3_close( l2data_sqlite3_conn_npcs );
l2data_sqlite3_conn_npcs = NULL;
sqlite3_close( l2data_sqlite3_conn_skills );
l2data_sqlite3_conn_skills = NULL;
return false;
}
//
l2data_sqlite3_was_init = 1;
#ifdef L2PACKETS_WINDOWS
InitializeCriticalSection( &l2data_db_cs );
#endif
return true;
}
return true;
}
#ifdef L2PACKETS_WINDOWS
void L2Data_DB_Lock() { EnterCriticalSection( &l2data_db_cs ); }
void L2Data_DB_UnLock() { LeaveCriticalSection( &l2data_db_cs ); }
#endif
#ifdef L2PACKETS_LINUX
// TODO: lock/unlock semaphore (mutex?)
// FIXED: (?) uses SQLITE_THREADSAFE definition to sqlite3 library
void L2Data_DB_Lock()
{
}
void L2Data_DB_UnLock()
{
}
#endif
void L2Data_DB_Free()
{
if( l2data_sqlite3_was_init )
{
L2Data_DB_Lock();
sqlite3_close( l2data_sqlite3_conn_items );
l2data_sqlite3_conn_items = NULL;
sqlite3_close( l2data_sqlite3_conn_npcs );
l2data_sqlite3_conn_npcs = NULL;
sqlite3_close( l2data_sqlite3_conn_skills );
l2data_sqlite3_conn_skills = NULL;
l2data_sqlite3_was_init = 0;
L2Data_DB_UnLock();
#ifdef L2PACKETS_WINDOWS
DeleteCriticalSection( &l2data_db_cs );
#endif
#ifdef L2PACKETS_LINUX
// TODO: linux: delete sync object
#endif
}
}
typedef struct st_L2DATA_2PARAM
{
char *param1;
char *param2;
} L2DATA_2PARAM, *PL2DATA_2PARAM;
int L2Data_sqlite_callback_2param( void *arg, int argc, char **argv, char **argvCol )
{
argvCol = NULL; // unreferenced formal parameter
PL2DATA_2PARAM pst = (PL2DATA_2PARAM)arg;
if( !pst ) return 0;
if( !argv ) return 0;
if( argc == 1 )
{
if( pst->param1 ) pst->param1[0] = 0;
if( argv[0] && pst->param1 ) strcpy( pst->param1, argv[0] );
}
else if( argc == 2 )
{
if( pst->param1 ) pst->param1[0] = 0;
if( pst->param2 ) pst->param2[0] = 0;
if( argv[0] && pst->param1 ) strcpy( pst->param1, argv[0] );
if( argv[1] && pst->param2 ) strcpy( pst->param2, argv[1] );
}
return 0;
}
// title can be NULL
bool L2Data_DB_GetNPCNameTitleByID( unsigned int npcID, char *name, char *title )
{
if( !l2data_sqlite3_conn_npcs ) return false;
L2Data_DB_Lock(); // lock
char *errmsg = NULL;
char query[128];
L2DATA_2PARAM st;
st.param1 = name;
st.param2 = title;
sprintf( query, "SELECT name,title FROM mobs WHERE id=%u", npcID );
int r = sqlite3_exec( l2data_sqlite3_conn_npcs, query, L2Data_sqlite_callback_2param, (void *)&st, &errmsg );
if( errmsg )
{
#if defined(_DEBUG) && defined(L2PACKETS_WINDOWS)
MessageBoxA( NULL, errmsg, "sqlite3 error (get NPC by ID)", MB_ICONSTOP );
#endif
#if defined(_DEBUG) && defined(L2PACKETS_LINUX)
fprintf( stderr, "sqlite3 error (get NPC by ID): %s\n", errmsg );
#endif
sqlite3_free( errmsg );
}
L2Data_DB_UnLock(); // unlock
return (r == SQLITE_OK);
}
// desc can be NULL
bool L2Data_DB_GetItemNamePicByID( unsigned int itemID, char *name, char *pic )
{
if( !l2data_sqlite3_conn_items ) return false;
L2Data_DB_Lock(); // lock
char *errmsg = NULL;
char query[128];
L2DATA_2PARAM st;
st.param1 = name;
st.param2 = pic;
sprintf( query, "SELECT name,pic FROM items WHERE id=%u", itemID );
int r = sqlite3_exec( l2data_sqlite3_conn_items, query, L2Data_sqlite_callback_2param, (void *)&st, &errmsg );
if( errmsg )
{
#if defined(_DEBUG) && defined(L2PACKETS_WINDOWS)
MessageBoxA( NULL, errmsg, "sqlite3 error (get item by id)", MB_ICONSTOP );
#endif
#if defined(_DEBUG) && defined(L2PACKETS_LINUX)
fprintf( stderr, "sqlite3 error (get item by ID): %s\n", errmsg );
#endif
sqlite3_free( errmsg );
}
L2Data_DB_UnLock(); // unlock
return (r == SQLITE_OK);
}
bool L2Data_DB_GetSkillNameByID( unsigned int skillID, char *name )
{
if( !l2data_sqlite3_conn_skills ) return false;
L2Data_DB_Lock(); // lock
char *errmsg = NULL;
char query[128];
L2DATA_2PARAM st;
st.param1 = name;
st.param2 = NULL;
sprintf( query, "SELECT name FROM skills WHERE id=%u", skillID );
int r = sqlite3_exec( l2data_sqlite3_conn_skills, query, L2Data_sqlite_callback_2param, (void *)&st, &errmsg );
if( errmsg )
{
#if defined(_DEBUG) && defined(L2PACKETS_WINDOWS)
MessageBoxA( NULL, errmsg, "sqlite3 error (get skill by ID)", MB_ICONSTOP );
#endif
#if defined(_DEBUG) && defined(L2PACKETS_LINUX)
fprintf( stderr, "sqlite3 error (get skill by ID): %s\n", errmsg );
#endif
sqlite3_free( errmsg );
}
L2Data_DB_UnLock(); // unlock
return (r == SQLITE_OK);
}
//#define L2DATA_RESULT_MAX_ROWS 64
int L2Data_sqlite_result_callback( void *pvResult, int colCount, char **colData, char **colName )
{
colName = NULL; // unreferenced formal parameter
L2Data_DB_Result *pResult = (L2Data_DB_Result *)pvResult;
if( !pResult ) return 0;
if( pResult->rowCount == 0 ) // current row number is 0, func called first time
{
pResult->colCount = colCount; // set column count in result set
// allocate row pointers array (maximum rows count limited :( )
pResult->rows = (char ***)malloc( pResult->inMaxRowsToGet * sizeof(char **) );
if( !pResult->rows ) return 0; // malloc() failed!
int i;
for( i=0; i<pResult->inMaxRowsToGet; i++ ) pResult->rows[i] = NULL;
}
if( pResult->rowCount >= pResult->inMaxRowsToGet ) return 0; // maximum reached, no more place
// allocate space for current row (colCount columns)
pResult->rows[ pResult->rowCount ] = (char **)malloc( colCount * sizeof( char* ) );
if( !pResult->rows[ pResult->rowCount ] ) return 0; // malloc failed! :(
// copy all coumns data to current row
int iCol;
for( iCol = 0; iCol < colCount; iCol++ )
{
if( colData[iCol] != NULL )
#ifdef L2PACKETS_WINDOWS
pResult->rows[ pResult->rowCount ][ iCol ] = _strdup( colData[iCol] ); // copy string to result set
#else // write own strdup() :)
pResult->rows[ pResult->rowCount ][ iCol ] = (char *)malloc( strlen( colData[iCol] ) + 1 );
if( pResult->rows[ pResult->rowCount ][ iCol ] ) strcpy( pResult->rows[ pResult->rowCount ][ iCol ], colData[iCol] );
#endif
else
pResult->rows[ pResult->rowCount ][ iCol ] = NULL; // NULL column value
}
//
pResult->rowCount++; // inc current row count in result set
return 0;
}
bool L2Data_DB_Query_NPCs_ByName( const char *request, L2Data_DB_Result *pResult )
{
if( !request || !pResult ) return false;
L2Data_DB_Lock(); // lock
char *errmsg = NULL;
char query[256];
sprintf( query, "SELECT id,name,title,level FROM mobs WHERE name LIKE '%s' ORDER BY name", request );
// zero result set
pResult->colCount = 0;
pResult->rowCount = 0;
pResult->rows = NULL;
// run query
int r = sqlite3_exec( l2data_sqlite3_conn_npcs, query,
L2Data_sqlite_result_callback,
(void *)pResult, // pass pointer to result set to callback
&errmsg );
if( errmsg )
{
#if defined(_DEBUG) && defined(L2PACKETS_WINDOWS)
MessageBoxA( NULL, errmsg, "sqlite3 error (L2Data_DB_Query_NPCs_ByName)", MB_ICONSTOP );
#endif
#if defined(_DEBUG) && defined(L2PACKETS_LINUX)
fprintf( stderr, "sqlite3 error (L2Data_DB_Query_NPCs_ByName): %s\n", errmsg );
#endif
sqlite3_free( errmsg );
}
L2Data_DB_UnLock(); // unlock
return (r == SQLITE_OK);
}
bool L2Data_DB_Query_Items_ByName( const char *request, L2Data_DB_Result *pResult )
{
if( !request || !pResult ) return false;
L2Data_DB_Lock(); // lock
char *errmsg = NULL;
char query[256];
sprintf( query, "SELECT id,name,pic FROM items WHERE name LIKE '%s' ORDER BY name", request );
// zero result set
pResult->colCount = 0;
pResult->rowCount = 0;
pResult->rows = NULL;
// run query
int r = sqlite3_exec( l2data_sqlite3_conn_items, query,
L2Data_sqlite_result_callback,
(void *)pResult, // pass pointer to result set to callback
&errmsg );
if( errmsg )
{
#if defined(_DEBUG) && defined(L2PACKETS_WINDOWS)
MessageBoxA( NULL, errmsg, "sqlite3 error (L2Data_DB_Query_Items_ByName)", MB_ICONSTOP );
#endif
#if defined(_DEBUG) && defined(L2PACKETS_LINUX)
fprintf( stderr, "sqlite3 error (L2Data_DB_Query_Items_ByName): %s\n", errmsg );
#endif
sqlite3_free( errmsg );
}
L2Data_DB_UnLock(); // unlock
return (r == SQLITE_OK);
}
bool L2Data_DB_Query_Skills_ByName( const char *request, L2Data_DB_Result *pResult )
{
if( !request || !pResult ) return false;
L2Data_DB_Lock(); // lock
char *errmsg = NULL;
char query[256];
sprintf( query, "SELECT id,name FROM skills WHERE name LIKE '%s' ORDER BY name", request );
// zero result set
pResult->colCount = 0;
pResult->rowCount = 0;
pResult->rows = NULL;
// run query
int r = sqlite3_exec( l2data_sqlite3_conn_skills, query,
L2Data_sqlite_result_callback,
(void *)pResult, // pass pointer to result set to callback
&errmsg );
if( errmsg )
{
#if defined(_DEBUG) && defined(L2PACKETS_WINDOWS)
MessageBoxA( NULL, errmsg, "sqlite3 error (L2Data_DB_Query_Skills_ByName)", MB_ICONSTOP );
#endif
#if defined(_DEBUG) && defined(L2PACKETS_LINUX)
fprintf( stderr, "sqlite3 error (L2Data_DB_Query_Skills_ByName): %s\n", errmsg );
#endif
sqlite3_free( errmsg );
}
L2Data_DB_UnLock(); // unlock
return (r == SQLITE_OK);
}
void L2Data_DB_Free_Result( L2Data_DB_Result *pResult )
{
if( !pResult ) return;
int rowCount = pResult->rowCount;
int colCount = pResult->colCount;
int ir, ic;
for( ir = 0; ir < rowCount; ir++ )
{
if( pResult->rows[ir] )
{
for( ic = 0; ic < colCount; ic++ )
{
if( pResult->rows[ir][ic] ) free( pResult->rows[ir][ic] );
}
free( pResult->rows[ir] );
}
}
free( pResult->rows );
pResult->rows = NULL;
pResult->colCount = 0;
pResult->rowCount = 0;
pResult->inMaxRowsToGet = 0;
}

File diff suppressed because it is too large Load Diff