Sign in to follow this  
Followers 0
Proglin

[Linux Compiling] Compiling NON-CVS on LINUX (like Yurots, Neverland..) UPDATED 30/03

159 posts in this topic

================================

VERSION 2.0 Last Update: 30/3/2006

================================

Note: This tutorial is only for advanced users

 

Hi all,

 

I'm kind of n00b in linux, so I've been trying to run no-cvs otserv on linux for a long time. Finally it works :)

And now i'm gonna give some extras tips ;)

 

Known problems that you have to deal with:

  • Linux is CASE-SENSITIVE so I suggest to you ONLY use lower case in ALL FILES (include /data/*)
  • Some NPCs use to crash... So remove all NPCs from /data/world/npcs.xml and start the server. If it runs, go adding 1 npc by time to know with npc is bugged. The "function onThink()" used on lua files used to stop working after some hours. Try to not use them.
  • It not works with SQL database

 

Let's rock ^_^

 

Linux system used to do this tutorial: Debian

 

Make sure to have all the libs:

  • apt-get install gcc
  • apt-get install automake
  • apt-get install libilua50
  • apt-get install libilua50-dev
  • apt-get install libilualib50-dev
  • apt-get install libboost-dev
  • apt-get install libboost*
  • apt-get install libxml2-dev
  • apt-get install libxml++2.6-dev

 

Create a directory and put all the sources in it (I'm using YurOTS_094d sources).

 

IMPORTANT UPDATE:

Create this two new files (in the same folder of your sources):

 

mypatch.h, with this content:

/* 
Patch: Make your no-cvs sources from otserv run in linux
by Ulisses - Brasil
Last update: Mar/2006
*/
#if defined(__linux__)

#define _itoa   itoa
#define  ltoa   itoa
#define _i64toa itoa
#define _timeb  timeb
#define _ftime  ftime

char* itoa(int value, char*  str, int radix);
#endif

 

mypatch.cpp, with this content:

/* 
Patch: Make your no-cvs sources from otserv run in linux
by Ulisses - Brasil
Last update: Mar/2006
*/

#include <stdio.h>
#include <string.h>

#if defined(__linux__)

#define _itoa   itoa
#define  ltoa   itoa
#define _i64toa itoa
#define _timeb  timeb
#define _ftime  ftime

char* itoa(int n, char *buff, int radix)
// convert a positive integer n to char *buff
// for instant, this function work with radix <= 10;
// a little change to run with radix > 10
{
    int q, r;
    int i = 0;
    char tmp[33];  // for radix = 2 and 32 bits computer
    do{
         q = int(n / radix);
         r = n % radix;
         n = q;
         tmp[i++] = 48 + r;
    }while(q > 0);
    int j;
    for(j = 0; j < i; j++){
         buff[j] = tmp[i - j - 1];
    }
    buff[j] = '\0';
    return buff;
}

#endif

 

Now in commands.cpp

After:

#include "monsters.h"

Add:

#include "mypatch.h"

 

In game.cpp

After:

#include "monsters.h"

Add:

#include "mypatch.h"

 

In guilds.cpp

After:

#include "player.h"

Add:

#include "mypatch.h"

 

In loginqueue.cpp

After:

#include "player.h"

Add:

#include "mypatch.h"

 

In tools.cpp

After:

#include <sys/timeb.h>

Add:

#include "mypatch.h"

 

 

Now is the most important thing: creating a Makefile

 

I have done this one:

(Create a file named Makefile in your source folder, with this content:)

#
# Make your no-cvs sources from otserv run in linux
# by Ulisses - Brasil
# Last update: Mar/2006
#
CC=g++

CFLAGS=-I. -I/usr/include/libxml2  -I/usr/include/lua50

LIBLINK=-L/usr/lib -lxml2 -lz -lpthread -lm -llualib50 -llua50 -lboost_thread -ldl

ENDFLAGS=-Werror -g -O2

OTSFLAGS=-D__linux__ -DUCB_AUTO_RESTART -DUCB_LVL_EXP -DYUR_LEARN_SPELLS -DCVS_DAY_CYCLE -DTLM_BUY_SELL -DTLM_SERVER_SAVE -DYUR_ROOKGARD -DTLM_HOUSE_SYSTEM -DBDB_UTEVO_LUX -DWOLV_LOAD_NPC -DBD_HOUSE_WINDOW -DTR_ANTI_AFK -DELEM_VIP_LIST -DTR_SUMMONS -DTRS_GM_INVISIBLE -DTLM_SKULLS_PARTY -DBRN_EXIVA -DSD_BURST_ARROW -DBDB_REPLACE_SPEARS -DBD_ITEM_LOOK -DSM_RELOAD_CONFIG -DJD_DEATH_LIST -DCT_EXANI_TERA -DTJ_MONSTER_BLOOD -DJD_WANDS -D__DEBUG_PLAYERS__ -DYUR_CVS_MODS -DYUR_ICE_RAPIER -DYUR_AOL -DYUR_LOGIN_QUEUE -DYUR_MULTIPLIERS -DYUR_BOH -DYUR_NPC_EXT -DYUR_GUILD_SYSTEM -DYUR_CMD_EXT -DYUR_ITEM_EXT -DYUR_ACT_EXT -DYUR_NO_MONSTER_HEAL -DYUR_PVP_ARENA -DYUR_RINGS_AMULETS -DYUR_CONFIG_CAP -DYUR_FIGHT_MODE -DYUR_READABLES -DYUR_HEAL_EXHAUST -DYUR_SHUTDOWN -DYUR_LIGHT_ITEM -DYUR_CLEAN_MAP -DYUR_GM_LOOK -DYUR_PREMIUM_PROMOTION -DYUR_INVISIBLE -DYUR_DRAINS -DEM_HUR_UP_DOWN -DPVTMSG -DJERO_PROTECTION -D__EXCEPTION_TRACER___

OBJ = account.o actions.o allocator.o chat.o commands.o container.o creature.o exception.o fileloader.o game.o guilds.o houses.o ioaccount.o ioaccountxml.o iomapbin.o iomapotbm.o iomapxml.o ioplayer.o ioplayerxml.o item.o itemloader.o items.o logger.o loginqueue.o luascript.o magic.o map.o md5.o monster.o monsters.o networkmessage.o npc.o otserv.o player.o position.o protocol.o protocol76.o pvparena.o readables.o scheduler.o spawn.o spells.o status.o summons.o thing.o tile.o tools.o mypatch.o

all: tibia

tibia: $(OBJ)
$(CC) $(CFLAGS) $(OTSFLAGS) $(ENDFLAGS) -o otserv $(OBJ) $(LIBLINK)

%.o:%.cpp
$(CC) $(CFLAGS) $(OTSFLAGS) $(ENDFLAGS) -c $+

 

Understanding this Makefile

CC= -> g++ is the compiler

CFFLAGS= -> libs include location

LIBLINK= -> libs used to make the executable

ENDFLAGS= -> (self explained)

OTSFLAGS= -> IMPORTANT: Here you should put all the parameters used in dev-c++. Put THE FIRST parameters: -D__linux__ and DO NOT USE THE BUGGED FLAG: -DYUR_HIGH_LEVELS.

OBJS -> Here you should put EVERY *.cpp changing the end to .o BUT DO NOT INCLUDE "database.cpp" IMPORTANTE UPDATE: You should add at the end the of this line: mypatch.o (like: game.cpp goes to: game.o)

 

After all this you should run: "make" and pray to works. If you have problemns in any file that try to add the code:

#include "mypatch.h"

 

Some tips:

  • otserv will ask from config.lua located in: /home/"username"/.otserv/config.lua
  • To make more confortable to change config.lua make a symbolic link from from /home/"username"/.otserv/config.lua to your real location.
  • Make sure that all files in ./data/ folder have read and write access.

 

If you get every thing running allright get this final tip ;) :

 

Final tip:

 

To make your server run in background (you dont need to stay logged ;) ) follow this steps:

  • apt-get install screen
  • creat a file named loopserver.sh with this content:
    #!/bin/bash
    
    #
    # Make your no-cvs sources from otserv run in linux
    # by Ulisses - Brasil
    # Last update: Mar/2006
    #
    
    i=1
    while [ $i -le 5000 ]
    do
    ./otserv 2>> ./ots-error.txt
    i=`expr $i + 1`
    done
    


  • In a Terminal:
  • Type: ./screen and in the window press "enter"
  • Type: ./loopserver.sh
  • Now to run the process in background (deatach) press: "CTRL+A" and after press "D"
  • You can logoff ;)
  • To reattach ( view the server output screen) type: ./screen -dr

 

Have fun! Good Luck!

 

Credits to me ;)

OsoSangre and Morpheus_BR like this

Share this post


Link to post
Share on other sites
Is it possible to compile a server for Linux on Windows or do you have to compile it in Linux aswell?

 

You have to compile on linux. (You can emulate linux on windows, but I think that you allways have to compile on linux)

Share this post


Link to post
Share on other sites

Great Greatttt tutorial!!

 

Going to compile right now on slackware!! :D

 

edit:

@Proglin

We can emule Linux on rWindows using VMware. In the program u can create a virtual partition and install linux/windows on it.

 

There is a version for rwindows and Linux.

 

Edit2:

 

ERROR:

-Werror -g -O2 -c monsters.cpp

monsters.cpp: In member function `MonsterType* Monsters::loadMonster(const

std::string&, const std::string&, bool)':

monsters.cpp:275: error: `_atoi64' undeclared (first use this function)

monsters.cpp:275: error: (Each undeclared identifier is reported only once for

each function it appears in.)

make: *** [monsters.o] Error 1

 

 

I put mypatch in monsters.cpp and on monsters.h but still errrrroorrr help pls :D

 

Compiling on slackware 10.2

Share this post


Link to post
Share on other sites

Do NOT use the option:

-DYUR_HIGH_LEVELS

 

I don't know how to implement the functions atoi64.

 

 

@ Morpheus_BR -> Plz, allways post a new reply. This way I can know . If you edit a post i don't receive notification

Share this post


Link to post
Share on other sites

@Proglin

 

Ths a lot brother, but what this do? :S

 

HIGHT_LEVELS ? :(

 

Using yurots 094d worked but using like neverland or mine sources get that error.. strange hun?

 

btw ths alot for this tuto :)

Share this post


Link to post
Share on other sites
@Proglin

 

Ths a lot brother, but what this do? :S

 

HIGHT_LEVELS ? :(

 

Using yurots 094d worked but using like neverland or mine sources get that error.. strange hun?

 

btw ths alot for this tuto :)

 

This option allows you work with 64 bits integer in windows.

Share this post


Link to post
Share on other sites

@Proglin =**

 

@Alreth

 

I'm having problems with lua lib... i can't found it for slackware. :S

 

When i resolv that problem i post some versions compiled :D

 

 

Can someone post the libs on tgz or rpm? That he post for download are for debian .deb

 

Or convert the deb for rpm/tgz

Share this post


Link to post
Share on other sites

If u are trying to built it in other distros and u canot find the libs... like boost headers (too much time to compile all boost)

 

Or devel libs.

 

Download the deb files and convert it on tar.gz files. Using this script

 

#!/bin/bash

###########################################################################
#
#	Shell program to Convert rpm and debian files to tar.gz format.
#
#	Copyright 2001, USM Bish <bish@nde.vsnl.net.in>.
#
#	This program is free software;  you can redistribute it and / or
#	modify it under the terms of the  GNU General Public License  as
#	published by the F ree Software Foundation;  either version 2 of 
#	the License, or (at your option) any later version. 
#
#	This program is  distributed in the hope that it will be useful, 
#	but  WITHOUT  ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#	General Public License for more details.
#
#
#	Usage:
#
#	2tgz.sh [ -h | --help ] [-d filename.deb] [-r filename.rpm]
#
#	Options:
#
#	-h, --help	      Display this help message and exit.
#	-d  filename.deb      Convert .deb file to tar.gz
#	-r  filename.rpm      Convert .rpm file to tar.gz
#
#
#	Revisions:
#
#	Aug/02/2001	File created   .......... Ver 0.1
#       Aug/02/2001     deb converter created ... Ver 0.2
#       Aug/03/2001     rpm converter added  .... Ver 0.3   
#
#       Dependencies on other utils:
#
#       o less      In case not installed, change value of
#                   MY_PAGER to your pager (viz view/ more etc.)
#       o ar        Needed for debian file conversion
#       o rpm2cpio  Needed for rpm conversion
#       o cpio      - do -
#
###########################################################################


###########################################################################
#	Constants
###########################################################################

PROGNAME=$(basename $0)
VERSION="0.3"
TEMP_FILE=/tmp/${PROGNAME}.$$

MY_PAGER=/usr/bin/less

###########################################################################
#	Functions
###########################################################################

function get_prefix
{
   echo $PACKAGE > $PROGNAME.1
   rev $PROGNAME.1 > $PROGNAME.2
   cat $PROGNAME.2 | cut -b 5- > $PROGNAME.1
   rev $PROGNAME.1 > $PROGNAME.2
   PREFIX=`cat $PROGNAME.2`
}

function view_tgz
{
  tar -tvvz < $PREFIX.tar.gz > $HOME/$PROGNAME.1
  cat $HOME/$PROGNAME.1 | awk '{print $1"\t"$3"\t"$6}' > $HOME/$PROGNAME.2
  echo -en "\nConstituents of tarball : $PREFIX.tar.gz\n\n" > $HOME/$PROGNAME.1
  echo -en "Permissions     Size    Contents\n\n" >> $HOME/$PROGNAME.1
  cat $HOME/$PROGNAME.2 >> $HOME/$PROGNAME.1
  cat $HOME/$PROGNAME.1 | $MY_PAGER
  clean_up
}

function done_message
{
  echo ""
  echo "Done .... Please unpack in a temporary directory"
  echo "Check that there are no filename conflicts ....."
  echo "You may like to do an *ldd* of binaries to check"
  echo "dependencies before installing."
  echo ""
  ls $PREFIX.*
  echo -en "\nView contents of "$PREFIX.tar.gz" [y/ n] .. "
  read YN
  if [ "$YN" = "y" ]; then
      view_tgz
  fi
  echo "Bye ... "  
}

function clean_up
{
       rm -f ${TEMP_FILE}
       rm -f $PROGNAME.1
       rm -f $PROGNAME.2
}


function graceful_exit
{
clean_up
exit
}


function error_exit 
{
echo "${PROGNAME}: ${1:-"Unknown Error"}" >&2
clean_up
exit 1
}


function term_exit
{
echo "${PROGNAME}: Terminated"
clean_up
exit
}


function int_exit
{
echo "${PROGNAME}: Aborted by user"
clean_up
exit
}


function usage
{
echo "Usage: ${PROGNAME} [-h | --help] [-d filename.deb] [-r filename.rpm]"
}

function helptext
{
#####
#	Function to display help message for program
#	No arguments
#####

local tab=$(echo -en "\t\t")

cat <<- -EOF-

       ${PROGNAME} ver. ${VERSION}	

       This is a program to Convert rpm and debian files to tar.gz format.

       $(usage)

       Options:

       -h, --help	      Display this help message and exit.
       -d  filename.deb      Convert .deb file to tar.gz
       -r  filename.rpm      Convert .rpm file to tar.gz

       Example: ${PROGNAME} -d package.deb  (to convert a .deb file)

-EOF-
}	


###########################################################################
#	Program starts here
###########################################################################

# Trap TERM, HUP, and INT signals and properly exit

trap term_exit TERM HUP
trap int_exit INT

# Process command line arguments

if [ "$1" = "--help" ]; then
   helptext
   graceful_exit
fi

if [ "$1" = "" ]; then
  if [ "$2" = "" ]; then
     helptext
     graceful_exit
  fi
fi

# Process arguments - edit to taste

while getopts ":hd:r:" opt; do

   case $opt in

   d ) echo $PROGNAME"  Debian .deb conversion" 

       PACKAGE="$2"
       get_prefix

       if [ -e $PACKAGE ]; then
           ar -x $PACKAGE
           rm -f control.tar.gz
           rm -f debian-binary
           mv data.tar.gz $PREFIX.tar.gz
           done_message
       else              # parm entered but incorrect
           echo "Debian package [$PACKAGE] not found" 
           echo "Quitting ... "
           clean_up
           exit 1  
       fi
       ;;

   r ) echo $PROGNAME"  RedHat .rpm conversion"

       PACKAGE="$2"
       get_prefix

       if [ -e $PACKAGE ]; then
           PD=`pwd`
           mkdir /tmp/2tgz
           rpm2cpio $PACKAGE > /tmp/2tgz/$PREFIX.cpio
           cd /tmp/2tgz
           cpio --extract --preserve-modification-time --make-directories < $PREFIX.cpio 1> /dev/null 2> /dev/null
           TARGET=`ls -d */`
           tar -cvvzf $PREFIX.tar.gz $TARGET 1> /dev/null 2> /dev/null
           cp $PREFIX.tar.gz $PD
           cd /tmp
           rm -rf 2tgz/
           cd $PD
           done_message
       else              # parm entered but incorrect
           echo "RedHat package [$PACKAGE] not found" 
           echo "Quitting ... "
           clean_up
           exit 1  
       fi
       ;;

   h ) helptext
       graceful_exit ;;

   * ) usage
exit 1

   esac

done

graceful_exit

#############################################################

 

Save this code on a file call the deb2tgz

 

do this with root

chmod +x deb2tgz

 

Than u should convert the deb pakage in tar.gz

deb2tgz nameofLib.deb

Than make a dir with the name of the lib

mkdir nameofLib

before move the tar.gz into that folder

mv nameofLib.tar.gz folderwiththename

 

Enter in the folder and untar that

 

tar -xvzf file.tar.gz

 

Than u should copy the files into the /

 

cp -rf src /

 

 

I think that should work... for it worked fine.

 

Just use this if u could not find some libs of the required post.

Merged post:

I'm having that problems with onthink()

 

There is another way to NPC gives bye when u leave or stop talking?

 

becouse if there is not, we can't use none npcs :(

 

 

And about that u told about case sensitive.. i'm having aproblem with the chars.. i have in acc accounts/1.xml with player GOD Test

 

and on players/GOD Test also in file GOD Test

 

But when i try to enter in ots he put my nick all low case. Can someone tell me when i change to sources interprete case-sensitive???

 

 

Pls helpppp :)

Share this post


Link to post
Share on other sites

Morpheus_BR, I use this function "onthink()" :

 

aol.lua script:

focus = 0
talk_start = 0
target = 0
following = false
attacking = false

function onThink()
if focus ~= 0 then
	if getDistanceToCreature(focus) > 3 then
		selfSay('Good bye then.')
		focus = 0
	end
end
end


function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
 	if focus == cid then
         selfSay('Good bye then.')
         focus = 0
         talk_start = 0
 	end
end


function onCreatureTurn(creature)

end

function msgcontains(txt, str)
 	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
 	msg = string.lower(msg)

 	if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 3 then
 		selfSay('Hello ' .. creatureGetName(cid) .. '! I sell scarfs (1k) and aols (10k).')

	focus = cid
 		talk_start = os.clock()

 	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 3 then
 		selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

 	elseif focus == cid then
	talk_start = os.clock()

	if msgcontains(msg, 'aol') then
		buy(cid,2173,1,10000)
	elseif msgcontains(msg, 'scarf') then
		buy(cid,2661,1,1000)

	elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 3 then
		selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
		focus = 0
		talk_start = 0
	end
 	end
end

Share this post


Link to post
Share on other sites

I think what he mean is that the onThing() function is crashing the server. I believe someone mentioned this earlier in the thread, no?

Share this post


Link to post
Share on other sites

Isn't crashing the server.. just don't work

 

I say hi to the NPC and he anwser me ok

 

I leave that room... I come back 15 minutes later and NPC still talking to me?

 

 

@Proglin

 

Is that working perfectly?

 

 

 

I'm having other problems with the case-sensitive. Becouse my player save on data/players/NiCk Of PlAyer

 

 

And otserv search on data/players/nick of player

 

 

All low-case

 

How can i fix it? To otserv search CASE SENSITIVE.. not only low-case ?

 

 

Ths a lot guys

Share this post


Link to post
Share on other sites

@morpheus:

 

Yes, the onthink() function work perfect here.

 

 

About sensitive case:

 

Do you create chars in PHP? If so, use strtolower() funtion:

$folder = './data/players/';
$newcharname = 'Proglin';
$filechar = $folder . $newcharname;
$filechar = strtolower($filechar);

 

Now you just have to write $filechar in disk

Share this post


Link to post
Share on other sites

Hummmm... but need to convert 60.000 players??? :S no sry hehehehe

 

 

the onthink function is working great ty for that example :D

 

 

But i will see what is the problem with the ots that doesnt work with case-sensitive :D

 

 

add on msn to talk?

 

morpheus@bc-rs.com

Share this post


Link to post
Share on other sites

I think I found where the problem was :)

 

I tested in here and all working, for case-sensitive of players.

 

 

Well.

 

In ioplayerxml.cpp

comment the function

std::transform (filename.begin(),filename.end(), filename.begin(), tolower);

 

 

Just put // in front of this

 

like

 

//std::transform (filename.begin(),filename.end(), filename.begin(), tolower);

 

And compile. Change all functions that has tolower.

 

 

If u got problems post here.

 

ps. I will compile some versions and post now :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0