Atrinik Server 2.5
Functions | Variables
server/main.c File Reference
#include <global.h>
#include <check_proto.h>

Go to the source code of this file.

Functions

static char * unclean_path (const char *src)
static void process_players1 ()
static void process_players2 ()
static void dequeue_path_requests ()
static void do_specials ()
void fatal (int err)
void version (object *op)
char * crypt_string (char *str, char *salt)
int check_password (char *typed, char *crypted)
void enter_player_savebed (object *op)
void leave_map (object *op)
static void enter_map (object *op, mapstruct *newmap, int x, int y, int pos_flag)
void set_map_timeout (mapstruct *map)
char * clean_path (const char *file)
static void enter_random_map (object *pl, object *exit_ob)
static void enter_unique_map (object *op, object *exit_ob)
void enter_exit (object *op, object *exit_ob)
void process_events (mapstruct *map)
void clean_tmp_files ()
void cleanup ()
int swap_apartments (const char *mapold, const char *mapnew, int x, int y, object *op)
static void iterate_main_loop ()
int main (int argc, char **argv)

Variables

static object marker
static const char *const branch_paths []
static uint32 branch_revision = 0

Detailed Description

Server main related functions.

Definition in file main.c.


Function Documentation

int check_password ( char *  typed,
char *  crypted 
)

Check if typed password and crypted password in the player file are the same.

Parameters:
typedThe typed password.
cryptedCrypted password from file.
Returns:
1 if the passwords match, 0 otherwise.

Definition at line 135 of file main.c.

char* clean_path ( const char *  file)

Takes a path and replaces all / with $.

We use strncpy so that we do not change the original string.

Parameters:
filePath to clean.
Returns:
Cleaned up path.

Definition at line 346 of file main.c.

void clean_tmp_files ( )

Clean temporary map files.

Definition at line 1087 of file main.c.

void cleanup ( )

Clean up everything before exiting.

Definition at line 1116 of file main.c.

char* crypt_string ( char *  str,
char *  salt 
)

Encrypt a string. Used for password storage on disk.

Parameters:
strThe string to crypt.
saltSalt, if NULL, random will be chosen.
Returns:
The crypted string.

Definition at line 104 of file main.c.

static void dequeue_path_requests ( ) [static]

Dequeue path requests.

Todo:
Only compute time if there is something more in the queue, something like if (path_request_queue_empty()) { break; }

Definition at line 1146 of file main.c.

static void do_specials ( ) [static]

Collection of functions to call from time to time.

Definition at line 1312 of file main.c.

void enter_exit ( object op,
object exit_ob 
)

Tries to move object to exit object.

Parameters:
opPlayer or monster object using the exit.
exit_obExit object (boat, exit, etc). If NULL, then CONTR(op)->maplevel contains that map to move the object to, which is used when loading the player object.

Definition at line 530 of file main.c.

static void enter_map ( object op,
mapstruct newmap,
int  x,
int  y,
int  pos_flag 
) [static]

Moves the player from current map (if any) to new map. map, x, y must be set.

If default map coordinates are to be used, then the function that calls this should figure them out.

Parameters:
opThe object we are moving
newmapMap to move the object to - it could be the map he just came from if the load failed for whatever reason.
xX position on the new map
yY position on the new map
pos_flagIf set, the function will not look for a free space and move the object, even if the position is blocked.

Definition at line 203 of file main.c.

void enter_player_savebed ( object op)

This is a basic little function to put the player back to his savebed. We do some error checking - it's possible that the savebed map may no longer exist, so we make sure the player goes someplace.

Parameters:
opThe player object entering his savebed.

Definition at line 146 of file main.c.

static void enter_random_map ( object pl,
object exit_ob 
) [static]

The player is trying to enter a randomly generated map. In this case, generate the random map as needed.

Parameters:
plThe player object entering the map.
exit_obExit object the player entered from.

Definition at line 409 of file main.c.

static void enter_unique_map ( object op,
object exit_ob 
) [static]

Code to enter/detect a character entering a unique map.

Parameters:
opPlayer object entering the map
exit_obExit object the player is entering from

Definition at line 454 of file main.c.

void fatal ( int  err)

Meant to be called whenever a fatal signal is intercepted. It will call the emergency_save() and the clean_tmp_files() functions.

Parameters:
errError level.

Definition at line 61 of file main.c.

static void iterate_main_loop ( ) [static]

Iterate the main loop.

Definition at line 1347 of file main.c.

void leave_map ( object op)

All this really is is a glorified remove_object that also updates the counts on the map if needed and sets map timeout if needed.

Parameters:
opThe object leaving the map.

Definition at line 177 of file main.c.

int main ( int  argc,
char **  argv 
)

The main function.

Parameters:
argcNumber of arguments.
argvArguments.
Returns:
0.

Definition at line 1393 of file main.c.

void process_events ( mapstruct map)

Process objects with speed, like teleporters, players, etc.

Parameters:
mapIf not NULL, only process objects on that map.

Definition at line 924 of file main.c.

static void process_players1 ( ) [static]

Do all player-related stuff before objects have been updated.

See also:
process_players2().

Definition at line 769 of file main.c.

static void process_players2 ( ) [static]

Do all player-related stuff after objects have been updated.

See also:
process_players1().

Definition at line 902 of file main.c.

void set_map_timeout ( mapstruct map)

Sets map timeout value.

Parameters:
mapThe map to set the timeout for.

Definition at line 318 of file main.c.

int swap_apartments ( const char *  mapold,
const char *  mapnew,
int  x,
int  y,
object op 
)

Swap one apartment (unique) map for another.

Parameters:
mapoldOld map path.
mapnewMap to switch for.
xX position where player's items from old map will go to.
yY position where player's items from old map will go to.
opPlayer we're doing the switching for.
Returns:
1 on success, 0 on failure.

Definition at line 1198 of file main.c.

static char * unclean_path ( const char *  src) [static]

Takes a path and replaces all $ with /.

This basically undoes clean_path().

We use strncpy so that we do not change the original string.

We are smart enough to start after the last / in case we are getting passed a string that points to a unique map path.

Parameters:
srcThe path to unclean.
Returns:
Uncleaned up path.

Definition at line 375 of file main.c.

void version ( object op)

Shows version information.

Parameters:
opIf NULL the version is logged using LOG(), otherwise it is shown to the player object using new_draw_info_format().

Definition at line 80 of file main.c.


Variable Documentation

const char* const branch_paths[] [static]
Initial value:
{
    ".", ".."
}

Where to search for .bzr directory.

Definition at line 44 of file main.c.

uint32 branch_revision = 0 [static]

Revision number of the branch, if any.

Definition at line 49 of file main.c.

object marker [static]

Object used in process_events().

Definition at line 42 of file main.c.