PAPACU
Intermediate OT User
- Joined
- Oct 10, 2019
- Messages
- 52
- Reaction score
- 118
Instructions for anti rollback
1- install gdb
sudo apt-get install gdb
2- compile the src with the flag for gdb
cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo ..
3- put the antirollback_config file in the ot folder (next to start.sh)
4- Edit start.sh to your OT folder
antirollback_config
start.sh
Extra edition!
in game.cpp
with these changes will send all players to the temple if the error occurs
1- install gdb
sudo apt-get install gdb
2- compile the src with the flag for gdb
cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo ..
3- put the antirollback_config file in the ot folder (next to start.sh)
4- Edit start.sh to your OT folder
antirollback_config
Lua:
set $_exitcode = 999
run
set $ec = $_exitcode
if $ec > 0
call g_game.saveGameState()
thread apply all bt full
end
quit $ec
start.sh
Lua:
#!/bin/bash
# script to run the automatic server again in case of crash
echo "Starting the program"
cd /home/papacu/papaglobalzuda
mkdir -p logs
# config mysql
usersql=""
servername=""
sqlpassword=""
date=`date "+%d-%m-%y-%H-%M-%S"`
filename="${servername}-${date}"
databasefile="${filename}.sql"
#necessary configurations for Anti-rollback
ulimit -c unlimited
set -o pipefail
while true
do
#the antirollback_config file must be in the tfs folder
gdb --batch -return-child-result --command=antirollback_config --args ./tfs 2>&1 | awk '{ print strftime("%F %T - "), $0; fflush(); }' | tee "logs/$(date +"%F %H-%M-%S.log")"
mysqldump -u$usersql -p$sqlpassword --add-drop-table --add-locks --allow-keywords --extended-insert --quick --compress $servername > /home/papacu/papaglobalzuda/database/$databasefile
gzip /home/papacu/papaglobalzuda/database/$databasefile-f
if [ $? -eq 0 ]; then
echo "Exit code 0, waiting 3 minutes..."
sleep 180 #3 minutos
else
echo "Crash !! Restarting the server in 5 seconds (The log file is saved in the logs folder)"
echo "If you want to shut down the server, press CTRL + C ..."
sleep 5
fi
done;
Extra edition!
in game.cpp
C++:
// Change function Game::saveGameState to the lines below
void Game::saveGameState(bool crash /= false/)
{
if (gameState == GAME_STATE_NORMAL) {
setGameState(GAME_STATE_MAINTAIN);
}
std::cout << "Saving server..." << std::endl;
for (const auto& it : players) {
if (crash) {
it.second->loginPosition = it.second->getTown()->getTemplePosition();
} else {
it.second->loginPosition = it.second->getPosition();
}
IOLoginData::savePlayer(it.second);
}
Map::save();
if (gameState == GAME_STATE_MAINTAIN) {
setGameState(GAME_STATE_NORMAL);
}
}
in game.h
//Search for saveGameState and change to the one below
void saveGameState(bool crash = false);
edit file antirollback_config
set $_exitcode = 999
run
if $_exitcode == 999
thread apply all bt full
call saveServer()
quit
end
if $_exitcode != 999
quit
end
in otserv.cpp
// Add at the end of the file after the last "}" add the following lines
#ifndef _WIN32
_attribute_ ((used)) void saveServer() {
if(g_game.getPlayersOnline() > 0)
g_game.saveGameState(true);
}
#endif
with these changes will send all players to the temple if the error occurs
Last edited by a moderator: