mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
svn -> git Migration
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
|
||||
#Mysql flags, for linuxthreads
|
||||
#MYSQL_FLAGS=`mysql_config --cflags`
|
||||
#MYSQL_LIB=`mysql_config --libs`
|
||||
MYSQL_FLAGS=-I'/usr/local/include/mysql'
|
||||
MYSQL_LIBS=-L'/usr/local/lib/mysql' -llmysqlclient -lz -lcrypt -lm
|
||||
|
||||
#linux threads flags:
|
||||
LTFLAGS=-I/usr/local/include/pthread/linuxthreads -D_GNU_SOURCE -D__USE_UNIX98 -D_REENTRANT -D_THREAD_SAFE
|
||||
LTLDFLAGS=-llthread -llstdc++ -llsupc++ -llgcc_r -L/usr/local/lib
|
||||
|
||||
CXXFLAGS=-ggdb -O -pipe -Wall -I. -I../common -fno-inline -DFREEBSD $(LTFLAGS) $(MYSQL_FLAGS)
|
||||
LDFLAGS=-lpcap -lz -rdynamic -O2 -ggdb -pipe -L/usr/local/lib $(LTLDFLAGS)
|
||||
|
||||
|
||||
include Makefile.common
|
||||
@@ -0,0 +1,26 @@
|
||||
#objects for EQ extractor
|
||||
PPOBJS=ppskillfix.o .obj/Mutex.o .obj/unix.o \
|
||||
.obj/dbcore.o
|
||||
|
||||
JOE= ExtractDB.o .obj/MiscFunctions.o Explorers.o ../common/misc.o \
|
||||
StructExplorer.o ../common/packet_dump.o ../common/buildfile.o \
|
||||
patches/versions.o patches/patch_021505.o patches/patch_current.o \
|
||||
patches/patch_local.o patches/patch_121504.o
|
||||
|
||||
all: ppskillfix
|
||||
|
||||
ppskillfix: $(PPOBJS)
|
||||
g++ -I.. $^ $(LDFLAGS) $(MYSQL_LIBS) -o $@
|
||||
|
||||
clean:
|
||||
rm -f ppskillfix $(PPOBJS)
|
||||
|
||||
.obj/%.o: ../../common/%.cpp ../../common/%.h
|
||||
mkdir -p .obj
|
||||
g++ -I.. $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.cpp %.h
|
||||
mkdir -p .obj
|
||||
g++ -I.. $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
#include "../common/debug.h"
|
||||
#include "../common/types.h"
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include <stdio.h>
|
||||
#include <mysql.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "../common/dbcore.h"
|
||||
|
||||
#define MAX_CONVERT_STEPS 10
|
||||
|
||||
int convert_profile_once(char *src, char *dst, int len);
|
||||
|
||||
int main() {
|
||||
|
||||
char host[200], user[200], passwd[200], database[200];
|
||||
int32 port=0;
|
||||
bool compression = false;
|
||||
bool items[6] = {false, false, false, false, false, false};
|
||||
|
||||
if(!DBcore::ReadDBINI(host, user, passwd, database, port, compression, items)) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!items[0] || !items[1] || !items[2] || !items[3])
|
||||
{
|
||||
printf ("Incomplete DB.INI file.\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
vector<char *> updates;
|
||||
|
||||
MYSQL m;
|
||||
MYSQL out;
|
||||
|
||||
mysql_init(&m);
|
||||
mysql_init(&out);
|
||||
|
||||
if(!mysql_real_connect(&m, host, user, passwd, database, 0, NULL, 0)) {
|
||||
printf("Unable to connect 1: %s.\n", mysql_error(&m));
|
||||
return(1);
|
||||
}
|
||||
if(!mysql_real_connect(&out, host, user, passwd, database, 0, NULL, 0)) {
|
||||
printf("Unable to connect 2: %s.\n", mysql_error(&m));
|
||||
return(1);
|
||||
}
|
||||
|
||||
if(mysql_query(&m, "SELECT id,name,profile FROM character_") != 0) {
|
||||
printf("Unable to query.\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
MYSQL_RES *res = mysql_use_result(&m);
|
||||
if(res == NULL) {
|
||||
printf("Unable to use res.\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
char *inbuffer = new char[sizeof(PlayerProfile_Struct)];
|
||||
PlayerProfile_Struct *in_pp = (PlayerProfile_Struct *) inbuffer;
|
||||
|
||||
MYSQL_ROW row;
|
||||
unsigned long *lengths;
|
||||
|
||||
int convert_count = 0;
|
||||
int correct_count = 0;
|
||||
int failed_count = 0;
|
||||
|
||||
while((row = mysql_fetch_row(res))) {
|
||||
lengths = mysql_fetch_lengths(res);
|
||||
unsigned long id = atoi(row[0]);
|
||||
|
||||
int curlen = lengths[2];
|
||||
|
||||
if(curlen != sizeof(PlayerProfile_Struct)) {
|
||||
fprintf(stderr, "Char '%s' has the wrong size. Expected %d, got %d\n", row[1], sizeof(PlayerProfile_Struct), curlen);
|
||||
failed_count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//make a copy of the version in the DB
|
||||
memcpy(inbuffer, row[2], curlen);
|
||||
|
||||
bool change = false;
|
||||
int r;
|
||||
for(r = 0; r < MAX_PP_SKILL; r++) {
|
||||
fprintf(stderr, "Char '%s' skill %d = %d\n", row[1], r, in_pp->skills[r]);
|
||||
if(in_pp->skills[r] == 254) {
|
||||
in_pp->skills[r] = 0;
|
||||
change = true;
|
||||
}
|
||||
}
|
||||
if(!change) {
|
||||
correct_count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Converting char %lu: %s...", id, row[1]);
|
||||
convert_count++;
|
||||
|
||||
char *outbuffer = new char[2*sizeof(PlayerProfile_Struct) + 512];
|
||||
|
||||
|
||||
//the correct profile ends up in inbuffer, so we can escape it into outbuffer
|
||||
char *bptr = outbuffer;
|
||||
bptr += snprintf(bptr, 128, "UPDATE character_ SET profile='");
|
||||
bptr += mysql_real_escape_string(&m, bptr, (const char *) inbuffer, sizeof(PlayerProfile_Struct));
|
||||
snprintf(bptr, 128, "' WHERE id=%lu", id);
|
||||
|
||||
// printf("Query: '%s'\n", outbuffer);
|
||||
//printf(outbuffer);
|
||||
//printf(";\n");
|
||||
/* if(mysql_query(&out, outbuffer) != 0) {
|
||||
failed_count++;
|
||||
printf(" Error updating char id %lu: %s\n", id, mysql_error(&m));
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
updates.push_back(outbuffer);
|
||||
fprintf(stderr, " done.\n");
|
||||
// convert_count++;
|
||||
}
|
||||
// mysql_free_result(res);
|
||||
|
||||
|
||||
vector<char *>::iterator cur, end;
|
||||
cur = updates.begin();
|
||||
end = updates.end();
|
||||
printf("Querying.");
|
||||
for(; cur != end; cur++) {
|
||||
/*if(mysql_query(&out, *cur) != 0) {
|
||||
failed_count++;
|
||||
printf(" Error updating some char: %s\n", mysql_error(&m));
|
||||
continue;
|
||||
}
|
||||
printf(".");
|
||||
fflush(stdout);*/
|
||||
delete[] *cur;
|
||||
|
||||
convert_count++;
|
||||
}
|
||||
|
||||
fprintf(stderr, "%d chars converted, %d errors, %d chars were up to date.\n", convert_count, failed_count, correct_count);
|
||||
|
||||
mysql_close(&m);
|
||||
mysql_close(&out);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
# Microsoft Developer Studio Project File - Name="ppskillfix" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=ppskillfix - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "ppskillfix.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "ppskillfix.mak" CFG="ppskillfix - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "ppskillfix - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "ppskillfix - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "ppskillfix - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W3 /GX /O2 /I "." /I ".." /I "../common" /I "c:\mysql\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib zlib.lib mysqlclient.lib /nologo /subsystem:console /machine:I386 /libpath:"c:\mysql\lib\opt" /libpath:"c:\eqemu\lib"
|
||||
|
||||
!ELSEIF "$(CFG)" == "ppskillfix - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "C:\Ihatewindows\Debug"
|
||||
# PROP Intermediate_Dir "C:\Ihatewindows\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "." /I ".." /I "../common" /I "c:\mysql\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib zlib.lib mysqlclient.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"c:\mysql\lib\opt" /libpath:"c:\eqemu\lib"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "ppskillfix - Win32 Release"
|
||||
# Name "ppskillfix - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\dbcore.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\Mutex.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ppskillfix.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "ppskillfix"=.\ppskillfix.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Reference in New Issue
Block a user