1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
#include "Maelstrom_Globals.h"
#include "object.h"
#include "player.h"
#include "globals.h"
#include "netplay.h"
/* Extra options specific to this logic module */
void LogicUsage(void)
{
error(
" -player N[@host][:port] # Designate player N (at host and/or port)\n"
" -server N@host[:port] # Play with N players using server at host\n"
" -deathmatch [N] # Play deathmatch to N frags (default = 8)\n"
);
}
/* Initialize special logic data */
int InitLogicData(void)
{
/* Initialize network player data */
if ( InitNetData() < 0 ) {
return(-1);
}
gDeathMatch = 0;
return(0);
}
/* Parse logic-specific command line arguments */
int LogicParseArgs(char ***argvptr, int *argcptr)
{
char **argv = *argvptr;
int argc = *argcptr;
/* Check for the '-player' option */
if ( strcmp(argv[1], "-player") == 0 ) {
if ( ! argv[2] ) {
error(
"The '-player' option requires an argument!\n");
PrintUsage();
}
if ( AddPlayer(argv[2]) < 0 )
exit(1);
++(*argvptr);
--(*argcptr);
return(0);
}
/* Check for the '-server' option */
if ( strcmp(argv[1], "-server") == 0 ) {
if ( ! argv[2] ) {
error("The '-server' option requires an argument!\n");
PrintUsage();
}
if ( SetServer(argv[2]) < 0 )
exit(1);
++(*argvptr);
--(*argcptr);
return(0);
}
/* Check for the '-deathmatch' option */
if ( strcmp(argv[1], "-deathmatch") == 0 ) {
if ( argv[2] && ((gDeathMatch=atoi(argv[2])) > 0) ) {
++(*argvptr);
--(*argcptr);
} else
gDeathMatch = 8;
return(0);
}
return(-1);
}
/* Do final logic initialization */
int InitLogic(void)
{
/* Make sure we have a valid player list */
if ( CheckPlayers() < 0 )
return(-1);
return(0);
}
void HaltLogic(void)
{
HaltNetData();
}
/* Initialize the player sprites */
int InitPlayerSprites(void)
{
int index;
OBJ_LOOP(index, gNumPlayers)
gPlayers[index] = new Player(index);
return(0);
}
int SpecialKey(SDL_Keysym key)
{
if ( key.sym == SDLK_F1 ) {
/* Special key -- switch displayed player */
if ( ++gDisplayed == gNumPlayers )
gDisplayed = 0;
return(0);
}
return(-1);
}
void SetControl(unsigned char which, int toggle)
{
QueueKey(toggle ? KEY_PRESS : KEY_RELEASE, which);
}
int GetScore(void)
{
return(OurShip->GetScore());
}
|