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 (char *mapold, char *mapnew, int x, int y, object *op) |
| static int | keyboard_press () |
| static void | process_keyboard_input (char *input) |
| static void | iterate_main_loop () |
| int | main (int argc, char **argv) |
Variables |
| static object | marker |
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:
-
| typed | The typed password. |
| crypted | Crypted password from file. |
- Returns:
- 1 if the passwords match, 0 otherwise.
Definition at line 129 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:
-
- Returns:
- Cleaned up path.
Definition at line 342 of file main.c.
Clean temporary map files.
Definition at line 1058 of file main.c.
Clean up everything before exiting.
Definition at line 1087 of file main.c.
| char* crypt_string |
( |
char * |
str, |
|
|
char * |
salt | |
|
) |
| | |
Encrypt a string. Used for password storage on disk.
- Parameters:
-
| str | The string to crypt. |
| salt | Salt, if NULL, random will be chosen. |
- Returns:
- The crypted string.
Definition at line 94 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 1117 of file main.c.
| static void do_specials |
( |
|
) |
[static] |
Collection of functions to call from time to time.
Definition at line 1283 of file main.c.
Tries to move object to exit object.
- Parameters:
-
| op | Player or monster object using the exit. |
| exit_ob | Exit 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 526 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:
-
| op | The object we are moving |
| newmap | Map to move the object to - it could be the map he just came from if the load failed for whatever reason. |
| x | X position on the new map |
| y | Y position on the new map |
| pos_flag | If set, the function will not look for a free space and move the object, even if the position is blocked. |
Definition at line 197 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:
-
| op | The player object entering his savebed. |
Definition at line 140 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:
-
| pl | The player object entering the map. |
| exit_ob | Exit object the player entered from. |
Definition at line 405 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:
-
| op | Player object entering the map |
| exit_ob | Exit object the player is entering from |
Definition at line 450 of file main.c.
| static void iterate_main_loop |
( |
|
) |
[static] |
Iterate the main loop.
Definition at line 1475 of file main.c.
| static int keyboard_press |
( |
|
) |
[static] |
Check if key was pressed in the interactive mode.
- Returns:
- 0 if no key was pressed, non zero otherwise
Definition at line 1319 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:
-
| op | The object leaving the map. |
Definition at line 171 of file main.c.
| int main |
( |
int |
argc, |
|
|
char ** |
argv | |
|
) |
| | |
The main function.
- Parameters:
-
| argc | Number of arguments. |
| argv | Arguments. |
- Returns:
- 0.
Definition at line 1517 of file main.c.
Process objects with speed, like teleporters, players, etc.
- Parameters:
-
| map | If not NULL, only process objects on that map. |
Definition at line 895 of file main.c.
| static void process_keyboard_input |
( |
char * |
input |
) |
[static] |
Process keyboard input by the interactive mode
- Parameters:
-
Definition at line 1336 of file main.c.
| static void process_players1 |
( |
|
) |
[static] |
| static void process_players2 |
( |
|
) |
[static] |
Sets map timeout value.
- Parameters:
-
| map | The map to set the timeout for. |
Definition at line 314 of file main.c.
| int swap_apartments |
( |
char * |
mapold, |
|
|
char * |
mapnew, |
|
|
int |
x, |
|
|
int |
y, |
|
|
object * |
op | |
|
) |
| | |
Swap one apartment (unique) map for another.
- Parameters:
-
| mapold | Old map path. |
| mapnew | Map to switch for. |
| x | X position where player's items from old map will go to. |
| y | Y position where player's items from old map will go to. |
| op | Player we're doing the switching for. |
- Returns:
- 1 on success, 0 on failure.
Definition at line 1169 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:
-
- Returns:
- Uncleaned up path.
Definition at line 371 of file main.c.
Shows version information.
- Parameters:
-
| op | If NULL the version is logged using LOG(), otherwise it is shown to the player object using new_draw_info_format(). |
Definition at line 77 of file main.c.
Variable Documentation
Object used in proccess_events().
Definition at line 46 of file main.c.