mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-05-20 08:26:59 -04:00
Compare commits
5 Commits
ioncannon/
...
8ceee35492
Author | SHA1 | Date | |
---|---|---|---|
|
8ceee35492 | ||
|
40b677f871 | ||
|
57e7ee1894 | ||
|
61069e6d49 | ||
|
0521b167fb |
110
Data/postbuild_copy.bat
Normal file
110
Data/postbuild_copy.bat
Normal 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
|
@@ -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
|
||||
|
@@ -70,21 +70,47 @@ namespace Meteor.Lobby
|
||||
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,29 +124,21 @@ 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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user