5 Commits

Author SHA1 Message Date
Robert Baker
8ceee35492 Batch script to copy all files for postbuild -- Reiichi001 2022-11-18 16:34:37 +00:00
Filip Maj
40b677f871 README.md edited online with Bitbucket 2022-11-18 16:31:52 +00:00
Robert Baker
57e7ee1894 Merged in Robert-Baker/importbat-had-a-line-missing-password-fi-1590334814488 (pull request #71)
import.bat had a line missing %PASSWORD% field for importing SQL files.

Approved-by: Filip Maj
2022-01-20 03:15:59 +00:00
PW Anon
61069e6d49 Merged in issue-21 (pull request #69)
Fix to Character Name Reservation

* Ported over changes from resharc/ffxiv-classic-server and merged into new branch.


Approved-by: Filip Maj
2022-01-20 03:15:31 +00:00
Filip Maj
0521b167fb README.md edited online with Bitbucket 2021-03-24 19:58:16 +00:00
4 changed files with 148 additions and 20 deletions

110
Data/postbuild_copy.bat Normal file
View File

@@ -0,0 +1,110 @@
@ECHO OFF
REM SETLOCAL
SET CWD = %~dp0
REM Echo Launch dir: "%~dp0"
REM Echo Current dir: "%CD%"
REM =============
REM COPY LOBBY CONFIG
REM =============
REM Required files: lobby_config.ini
SET /a foundlfolders = 0
if exist "%~dp0\..\Lobby Server\bin\Debug" (
SET /a foundlfolders = %foundlfolders% + 1
echo Found Lobby Debug build folder.
echo Copying lobby_config.ini if needed...
xcopy lobby_config.ini "%~dp0\..\Lobby Server\bin\Debug\" /d /y /q
)
if exist "%~dp0\..\Lobby Server\bin\Release" (
SET /a foundlfolders = %foundlfolders% + 1
echo Found Lobby Release build folder.
echo Copying lobby_config.ini if needed...
xcopy lobby_config.ini "%~dp0\..\Lobby Server\bin\Release\" /d /y /q
)
if %foundlfolders% LSS 1 (
echo Could not find debug or release folder for the Lobby server. Please compile the project first!
)
REM =============
REM COPY WORLD CONFIG
REM =============
REM Required files: world_config.ini
SET /a foundwfolders = 0
if exist "%~dp0\..\World Server\bin\Debug" (
SET /a foundwfolders = %foundwfolders% + 1
echo Found World Debug build folder.
echo Copying world_config.ini if needed...
xcopy world_config.ini "%~dp0\..\World Server\bin\Debug\" /d /y /q
)
if exist "%~dp0\..\World Server\bin\Release" (
SET /a foundwfolders = %foundwfolders% + 1
echo Found World Release build folder.
echo Copying world_config.ini if needed...
xcopy world_config.ini "%~dp0\..\World Server\bin\Release\" /d /y /q
)
if %foundwfolders% LSS 1 (
echo Could not find debug or release folder for the World server. Please compile the project first!
)
REM =============
REM COPY MAP CONFIG
REM =============
REM Required files: map_config.ini staticactors.bin scripts/
SET /a foundmfolders = 0
if exist "%~dp0\..\Map Server\bin\Debug" (
SET /a foundmfolders = %foundmfolders% + 1
echo Found Map Debug build folder.
echo Copying map_config.ini if needed...
xcopy map_config.ini "%~dp0\..\Map Server\bin\Debug\" /d /y /q
if exist staticactors.bin (
echo Copying staticactors.bin if needed...
xcopy staticactors.bin "%~dp0\..\Map Server\bin\Debug\" /d /y /q
) else (
echo Cannot copy the staticactors.bin file because it doesn't exist in data\
)
echo Copying scripts folder if needed...
xcopy scripts "%~dp0\..\Map Server\bin\Debug\scripts\" /e /d /y /s /q
)
if exist "%~dp0\..\Map Server\bin\Release" (
SET /a foundmfolders = %foundmfolders% + 1
echo Found Map Release build folder.
echo Copying map_config.ini if needed...
xcopy map_config.ini "%~dp0\..\Map Server\bin\Release\" /d /y /q
if exist staticactors.bin (
echo Copying staticactors.bin if needed...
xcopy staticactors.bin "%~dp0\..\Map Server\bin\Release\" /d /y /q
) else (
echo Cannot copy the staticactors.bin file because it doesn't exist in data\
)
echo Copying scripts folder if needed...
xcopy scripts "%~dp0\..\Map Server\bin\Release\scripts\" /e /d /y /s /q
)
if %foundmfolders% LSS 1 (
echo Could not find debug or release folder for the Map server. Please compile the project first!
)
Pause

View File

@@ -27,7 +27,7 @@ ECHO Creating new database
ECHO Loading tables into the database
cd %PATH_SQL%
FOR %%X IN (*.sql) DO ECHO Importing %%X & %PATH_MYSQL% %DBNAME% -h %DBADDRESS% -u %USER% < %%X
FOR %%X IN (*.sql) DO ECHO Importing %%X & %PATH_MYSQL% %DBNAME% -h %DBADDRESS% -u %USER% %PASSWORD% < %%X
ECHO Finished!
ENDLOCAL

View File

@@ -68,23 +68,49 @@ namespace Meteor.Lobby
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
{
try
{
{
conn.Open();
//Check if exists
MySqlCommand cmd = new MySqlCommand("SELECT * FROM characters WHERE name=@name AND serverId=@serverId AND state != 2 AND state != 1", conn);
pid = 0;
cid = 0;
//Check if there exists a character not reserved by the user with the same name and in the same server
MySqlCommand cmd = new MySqlCommand("SELECT * FROM characters WHERE (name=@name AND serverId=@serverId AND (userId!=@userId OR state!=0))", conn);
cmd.Parameters.AddWithValue("@serverId", serverId);
cmd.Parameters.AddWithValue("@name", name);
cmd.Parameters.AddWithValue("@userId", userId);
using (MySqlDataReader Reader = cmd.ExecuteReader())
{
if (Reader.HasRows)
{
alreadyExists = true;
Program.Log.Debug("[SQL] Found character with same name. Exiting...");
return true; //Early exit as we don't need to bother with anything else in this.
}
}
//Reserve
if (!alreadyExists)
//Now check for a reserved character
MySqlCommand cmd3 = new MySqlCommand("SELECT * FROM characters WHERE userId=@userId AND state=0", conn);
cmd3.Parameters.AddWithValue("@userId", userId);
using (MySqlDataReader Reader = cmd3.ExecuteReader())
{
if (Reader.HasRows) //We can reasonably assume that there's only one reserved character per used id
{
Reader.Read();
cid = Reader.GetUInt16(0);
pid = 0xBABE;
}
}
if (cid != 0) //Update our reservation
{
MySqlCommand cmd2 = new MySqlCommand();
cmd2.Connection = conn;
cmd2.CommandText = "UPDATE characters SET serverId = @serverId, name = @name WHERE id = @cid";
cmd2.Prepare();
cmd2.Parameters.AddWithValue("@serverId", serverId);
cmd2.Parameters.AddWithValue("@name", name);
cmd2.Parameters.AddWithValue("@cid", cid);
cmd2.ExecuteNonQuery();
} else //Reserve
{
MySqlCommand cmd2 = new MySqlCommand();
cmd2.Connection = conn;
@@ -98,31 +124,23 @@ namespace Meteor.Lobby
cid = (ushort)cmd2.LastInsertedId;
pid = 0xBABE;
}
else
{
pid = 0;
cid = 0;
}
}
catch (MySqlException e)
{
Program.Log.Error(e.ToString());
Program.Log.Error(e.ToString());
pid = 0;
cid = 0;
pid = 0;
}
finally
{
conn.Dispose();
}
Program.Log.Debug("[SQL] CID={0} Created on 'characters' table.", cid);
}
return alreadyExists;
}
}
public static void MakeCharacter(uint accountId, uint cid, CharaInfo charaInfo)
{

View File

@@ -7,7 +7,7 @@ If you wish to discuss and help please join the Discord server.
**Discord Server Invite**
https://discord.gg/0ynLxiEl0zWhpKOW
https://discord.gg/fBmGkSZbaD
Pull Requests
========