git.shiar.nl
/
netris.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
reformat piece table code so shapes are better discernable
[netris.git]
/
client.c
diff --git
a/client.c
b/client.c
index b8b7eed3b47c735656f06f88d6fa65d4961e950c..013757261d907f97c0be72555406a4228baa3c50 100644
(file)
--- a/
client.c
+++ b/
client.c
@@
-73,11
+73,11
@@
static char *cmds[] = {
};
static char *hostStr;
};
static char *hostStr;
-static
int
paused = 0;
+static
bool
paused = 0;
static char lastadd;
static char lastadd;
-void handle_setkeys(char *newKeys)
+
static
void handle_setkeys(char *newKeys)
{
int i, k, ch;
char used[256];
{
int i, k, ch;
char used[256];
@@
-113,7
+113,7
@@
void handle_setkeys(char *newKeys)
exit(1);
}
exit(1);
}
-void Usage(void)
+
static
void Usage(void)
{
Header();
fprintf(stderr,
{
Header();
fprintf(stderr,
@@
-133,15
+133,12
@@
void Usage(void)
" -t, --team <team>\tJoin a team (don't receive lines from your teammates)\n"
" -l, --level <lvl>\tBegin at a higher level (can be used as handicap)\n"
" -k, --keys <keys>\tRemap keys (default is \"%s\" for cursors)\n"
" -t, --team <team>\tJoin a team (don't receive lines from your teammates)\n"
" -l, --level <lvl>\tBegin at a higher level (can be used as handicap)\n"
" -k, --keys <keys>\tRemap keys (default is \"%s\" for cursors)\n"
- "\n"
- " -r, --robot <cmd>\tExecute program to control the game instead of keyboard\n"
- " -F, --fair-robot\tUse fair robot interface\n"
"\n",
DEFAULT_PORT, DEFAULT_KEYS
);
}
"\n",
DEFAULT_PORT, DEFAULT_KEYS
);
}
-void handle_arg(char tag, char *value)
+
static
void handle_arg(char tag, char *value)
{
switch (tag) {
case 'a': //ascii
{
switch (tag) {
case 'a': //ascii
@@
-149,7
+146,7
@@
void handle_arg(char tag, char *value)
Sets.drawstyle &= ~Sets.ascii;
break;
case 'c': //connect
Sets.drawstyle &= ~Sets.ascii;
break;
case 'c': //connect
-
gam
e = GT_classicTwo;
+
Game.typ
e = GT_classicTwo;
hostStr = value;
break;
case 'p': //port
hostStr = value;
break;
case 'p': //port
@@
-192,7
+189,7
@@
void handle_arg(char tag, char *value)
}
}
}
}
-void handle_conffile(char *filename)
+
static
void handle_conffile(char *filename)
{
FILE *file_in;
char buf[513];
{
FILE *file_in;
char buf[513];
@@
-225,7
+222,7
@@
void handle_conffile(char *filename)
} //defaults
}
} //defaults
}
-int game_piece(int scr, char shape)
+
static
int game_piece(int scr, char shape)
{
Players[scr].score.pieces++;
{
{
Players[scr].score.pieces++;
{
@@
-245,17
+242,16
@@
int game_piece(int scr, char shape)
return 1;
}
return 1;
}
-void game_setpaused(void)
+
static
void game_setpaused(void)
{ //check whether anyone paused the game
int i;
paused = Game.started < 1;
for (i = 1; i < MAX_SCREENS; i++) if (Players[i].alive > 0)
{ //check whether anyone paused the game
int i;
paused = Game.started < 1;
for (i = 1; i < MAX_SCREENS; i++) if (Players[i].alive > 0)
- paused |= Players[i].flags & SCF_paused;
- if (paused) paused = 1;
+ paused |= (Players[i].flags & SCF_paused) != 0;
}
}
-void game_reset(void)
+
static
void game_reset(void)
{ //init new game
int i;
{ //init new game
int i;
@@
-278,7
+274,7
@@
void game_reset(void)
InitFields();
}
InitFields();
}
-void game_clear(int scr)
+
static
void game_clear(int scr)
{ //check for full lines
int linesCleared;
int linevalues[] = { 40, 100, 400, 1200, }; //= 50*lines! - 10*(lines==1)
{ //check for full lines
int linesCleared;
int linevalues[] = { 40, 100, 400, 1200, }; //= 50*lines! - 10*(lines==1)
@@
-288,7
+284,7
@@
void game_clear(int scr)
2500, 3000, 3500, 4000, 4500, 5000, 6000, 7500 };
if ((linesCleared = ClearFullLines(scr)) > 0) {
2500, 3000, 3500, 4000, 4500, 5000, 6000, 7500 };
if ((linesCleared = ClearFullLines(scr)) > 0) {
- if (
gam
e == GT_onePlayer)
+ if (
Game.typ
e == GT_onePlayer)
if ((Players[scr].score.lines / 10) <
((Players[scr].score.lines+linesCleared)/10)) {
if ((Game.speed /= SPEEDINC) < SPEEDMINIMUM)
if ((Players[scr].score.lines / 10) <
((Players[scr].score.lines+linesCleared)/10)) {
if ((Game.speed /= SPEEDINC) < SPEEDMINIMUM)
@@
-301,7
+297,7
@@
void game_clear(int scr)
Players[scr].score.lines += linesCleared;
Players[scr].score.adds += linesCleared - (linesCleared < 4); //XXX match handicap
if (scr == me) {
Players[scr].score.lines += linesCleared;
Players[scr].score.adds += linesCleared - (linesCleared < 4); //XXX match handicap
if (scr == me) {
- if (
gam
e == GT_classicTwo) {
+ if (
Game.typ
e == GT_classicTwo) {
SendPacket(scr, NP_clear, 0, NULL);
if (linesCleared > 1) {
short junkLines;
SendPacket(scr, NP_clear, 0, NULL);
if (linesCleared > 1) {
short junkLines;
@@
-322,7
+318,7
@@
void game_clear(int scr)
} //lines cleared
}
} //lines cleared
}
-void game_loop(void)
+
static
void game_loop(void)
{
bool changed = 0;
short gameStatus = 2; //2=loop; 1=new piece; 0=quit
{
bool changed = 0;
short gameStatus = 2; //2=loop; 1=new piece; 0=quit
@@
-347,7
+343,7
@@
void game_loop(void)
Message(Players[me].flags & SCF_paused
? "You are not ready" : "You are ready");
game_setpaused();
Message(Players[me].flags & SCF_paused
? "You are not ready" : "You are ready");
game_setpaused();
- if (
gam
e == GT_classicTwo)
+ if (
Game.typ
e == GT_classicTwo)
SendPacket(me, NP_pause, 0, NULL);
ShowPause(me);
changed = 1;
SendPacket(me, NP_pause, 0, NULL);
ShowPause(me);
changed = 1;
@@
-387,7
+383,7
@@
void game_loop(void)
Message("<\\%d%s\\7> %s",
Players[me].team > 7 ? 7 : Players[me].team,
Players[me].name, chatText);
Message("<\\%d%s\\7> %s",
Players[me].team > 7 ? 7 : Players[me].team,
Players[me].name, chatText);
- if (
gam
e == GT_classicTwo)
+ if (
Game.typ
e == GT_classicTwo)
SendPacket(me, NP_msg, strlen(chatText) + 1, chatText);
}
SendPacket(me, NP_msg, strlen(chatText) + 1, chatText);
}
@@
-478,7
+474,7
@@
void game_loop(void)
gameStatus = 1; // drop
break;
case KT_faster:
gameStatus = 1; // drop
break;
case KT_faster:
- if (
gam
e != GT_onePlayer) break;
+ if (
Game.typ
e != GT_onePlayer) break;
if ((Game.speed /= SPEEDINC) < SPEEDMINIMUM)
Game.speed = SPEEDMINIMUM;
SetITimer(Game.speed, SetITimer(0, 0));
if ((Game.speed /= SPEEDINC) < SPEEDMINIMUM)
Game.speed = SPEEDMINIMUM;
SetITimer(Game.speed, SetITimer(0, 0));
@@
-613,9
+609,6
@@
void game_loop(void)
} //stop game
case NP_newPlayer:
{
} //stop game
case NP_newPlayer:
{
- char teams[10][7] = { "", "Green", "Cyan", "Blue", "Purple",
- "Red", "Grey", "White", "*Orange" };
-
if (net.uid>maxPlayer) maxPlayer = net.uid;
memcpy(&Players[net.uid], net.data, net.size);
ClearField(net.uid);
if (net.uid>maxPlayer) maxPlayer = net.uid;
memcpy(&Players[net.uid], net.data, net.size);
ClearField(net.uid);
@@
-624,7
+617,7
@@
void game_loop(void)
Message("%s joined the game", Players[net.uid].name);
else
Message("%s joined %s team", Players[net.uid].name,
Message("%s joined the game", Players[net.uid].name);
else
Message("%s joined %s team", Players[net.uid].name,
- team
s
[Players[net.uid].team]);
+ team
name
[Players[net.uid].team]);
if (Players[net.uid].flags & SCF_paused) {
game_setpaused();
} //player has paused
if (Players[net.uid].flags & SCF_paused) {
game_setpaused();
} //player has paused
@@
-702,7
+695,7
@@
void game_loop(void)
else Message("\\%d%s fragged you",
Players[lastadd].team > 7 ? 7 : Players[lastadd].team,
Players[lastadd].name);
else Message("\\%d%s fragged you",
Players[lastadd].team > 7 ? 7 : Players[lastadd].team,
Players[lastadd].name);
- if (
gam
e == GT_classicTwo)
+ if (
Game.typ
e == GT_classicTwo)
SendPacket(me, NP_argghhh, sizeof(lastadd), &lastadd);
ShowPause(me);
changed = 1;
SendPacket(me, NP_argghhh, sizeof(lastadd), &lastadd);
ShowPause(me);
changed = 1;
@@
-769,7
+762,7
@@
int main(int argc, char **argv)
{
char ch;
{
char ch;
-
gam
e = GT_onePlayer;
+
Game.typ
e = GT_onePlayer;
port = DEFAULT_PORT;
maxPlayer = 1;
Game.initspeed = DEFAULT_INTERVAL;
port = DEFAULT_PORT;
maxPlayer = 1;
Game.initspeed = DEFAULT_INTERVAL;
@@
-812,7
+805,7
@@
int main(int argc, char **argv)
InitScreens(); //setup screen
InitScreens(); //setup screen
- if (
gam
e == GT_classicTwo) {
+ if (
Game.typ
e == GT_classicTwo) {
spied = 1;
InitiateConnection(hostStr, port);
HandShake();
spied = 1;
InitiateConnection(hostStr, port);
HandShake();