for (x = 0; x < Players[scr].boardWidth; ++x) {
oldBoard[scr][y][x] = board[scr][y][x] = BT_none;
}
-} //ClearField
+}
unsigned char GetBlock(int scr, int y, int x)
{ //Returns the block on field at position (x,y)
return BT_none;
else
return board[scr][y][x];
-} //GetBlock
+}
void SetBlock(int scr, int y, int x, unsigned char type)
{
board[scr][y][x] = type;
changed[scr][y] |= 1 << x;
}
-} //SetBlock
+}
int RefreshBoard(int scr)
{ //draw changes to screen
any = 1;
} //changed row
return any;
-} //RefreshBoard
+}
int GlanceFunc(int scr, int y, int x, unsigned char type)
{
PlotBlockXY(y, x, type);
return 0;
-} //GlanceFunc
+}
int ShadowFunc(int scr, int y, int x, unsigned char type)
{ //draw shadow
SetBlock(scr, y, x, BT_shadow);
return 0;
-} //ShadowFunc
+}
int PlotFunc(int scr, int y, int x, unsigned char type)
{
ShapeIterate(shape, scr, shadowy + 1, x, ShadowFunc);
} //draw shadow
ShapeIterate(shape, scr, y, x, PlotFunc);
-} //PlotShape
+}
int EraseFunc(int scr, int y, int x, unsigned char type)
{
ShapeIterate(shape, scr, y, x, EraseFunc);
if (shadow && scr == me) //draw shadow
ShapeIterate(shape, scr, shadowy + 1, x, EraseFunc);
-} //EraseShape
+}
int CollisionFunc(int scr, int y, int x, unsigned char type)
{
int ShapeFits(char shape, int scr, int y, int x)
{ //check if there's nothing in the way
return !ShapeIterate(shape, scr, y, x, CollisionFunc);
-} //ShapeFits
+}
int VisibleFunc(int scr, int y, int x, unsigned char type)
{
int ShapeVisible(char shape, int scr, int y, int x)
{
return ShapeIterate(shape, scr, y, x, VisibleFunc);
-} //ShapeVisible
+}
int MovePiece(int scr, int deltaY, int deltaX)
{
PlotShape(Players[scr].curShape, scr, Players[scr].curY, Players[scr].curX,
scr == me);
return result;
-} //MovePiece
+}
int RotatePiece(int scr, int dir)
{
PlotShape(Players[scr].curShape, scr,
Players[scr].curY, Players[scr].curX, scr == me);
return result;
-} //RotatePiece
+}
int DropPiece(int scr)
{
PlotShape(Players[scr].curShape, scr,
Players[scr].curY, Players[scr].curX, 0);
return count;
-} //DropPiece
+}
int BlockFree(int scr, int x, int y, unsigned char z)
{ //Check if blocks are empty below block (x,y) and sticking to (x,y) mask <z>
else break;
PlotShape(Players[scr].curShape, scr, Players[scr].curY, Players[scr].curX,
scr == me);
-} //InoertJunk
+}
/*
* vi: ts=4 ai
for (i = 0; i<MSG_HEIGHT; i++)
message[i] = messages[i]; //set pointers
}
-} //InitScreens
+}
void CleanupScreens(void)
{
RemoveEventGen(&keyGen);
endwin(); //end curses
OutputTermStr(term_ve, 1);
-} //CleanupScreens
+}
void GetTermcapInfo(void)
{
}
if (!term_vi || !term_ve)
term_vi = term_ve = NULL;
-} //GetTermcapInfo
+}
void OutputTermStr(char *str, int flush)
{
fputs(str, stdout);
if (flush) fflush(stdout);
}
-} //OutputTermStr
+}
void DrawTitle(void)
{
else memcpy(&s[cols], "\0", 1);
mvaddstr(0, 0, s);
standend(); //normal text
-} //DrawTitle
+}
void DrawBox(int x1, int y1, int x2, int y2)
{ //draw grid
for (x = x1 + 1; x < x2; x++)
addch(Sets.ascii ? '-' : ACS_HLINE);
addch(Sets.ascii ? '+' : ACS_LRCORNER);
-} //DrawBox
+}
void DrawField(int scr)
{ //draw field for player scr
} //draw field
ShowPause(scr);
-} //DrawField
+}
void InitFields(void)
{ //calculate positions of all fields
}
for (scr = 1; scr <= maxPlayer; scr++)
DrawField(scr);
-} //InitFields
+}
void CleanupScreen(int scr)
{
waddstr(msgwin, p);
if (haveColor) wstandend(msgwin);
waddch(msgwin, '\n');
-} //DisplayMessage
+}
void Message(char *fmt, ...)
{ //print game/bot message
DisplayMessage(s);
wclrtoeol(msgwin);
wrefresh(msgwin);
-} //Message
+}
void Messagetype(char c, int x, char *s)
{ //show single typed character
mvwaddch(msgwin, messageHeight - 1, (x+1) % (messageWidth-1), '_');
} //typing mode
wrefresh(msgwin);
-} //Messagetype
+}
void PlotBlock1(int y, int x, unsigned char type)
{ //display block on screen
if (Sets.standout) standend();
#endif
} //display one brick
-} //PlotBlock1
+}
void PlotBlock1S(int y, int x, unsigned char type)
{ //display block small
move(y, x);
if (Sets.standout) standend();
#endif
} //display one brick
-} //PlotBlock1S
+}
void PlotBlock(int scr, int y, int x, unsigned char type)
{
if (y >= 0 && y < Players[scr].boardVisible &&
else
PlotBlock1S(boardYPos[scr] - y, boardXPos[scr] + x, type);
} //on screen
-} //PlotBlock
+}
void PlotBlockXY(int y, int x, unsigned char type)
{ //Draw block at specified position on screen (not on field)
PlotBlock1(20 - y, 2 * x, type);
-} //PlotBlock
+}
void ShowScore(int scr, struct _Score score)
{ //show score stuff
for (i = 7; i <= 10; i++)
mvaddstr(i, statusXPos, " ");
} //too early to display stats, remove old..
-} //ShowScore
+}
void FieldMessage(int playa, char *message)
{ //put a message over playa's field
for (x = 0; x <= Players[playa].boardWidth; x++)
PlotBlock(playa, y, x, GetBlock(playa, y, x));
} //restore field
-} //FieldMessage
+}
void ShowPause(int playa)
{ //put paused over player's field
boardSize[playa] > 1 ? "G A M E O V E R" : "GAME OVER");
else
FieldMessage(playa, boardSize[playa] > 1 ? "E M P T Y" : "EMPTY");
-} //ShowPause
+}
void ShowTime(void)
{ //display timer
mvprintw(statusYPos, statusXPos, "timer %7.0f ", CurTimeval() / 1e6);
-} //ShowTime
+}
void ScheduleFullRedraw(void)
{
touchwin(stdscr);
-} //ScheduleFullRedraw
+}
void CatchWinCh(int sig)
{ //handle window resize
refresh(); //and reinit display (with different sizes)
InitFields(); //manually redraw everything
refresh(); //refresh
-} //CatchWinCh
+}
static MyEventType KeyGenFunc(EventGenRec *gen, MyEvent *event)
{ //read keypresses
return E_key;
else
return E_none;
-} //KeyGenFunc
+}
/*
* vi: ts=4 ai
}
if (errs)
exit(1);
-} //MapKeys
+}
void WriteConf(void)
{
fclose(file_out);
fprintf(stderr, "Wrote new game configuration to %s\n", CONFIG_FILE);
-} //WriteConf
+}
void HandleOption(char tag, char *value)
{
default:
Usage(); exit(1);
}
-} //HandleParam
+}
void ReadConf(char *filename)
{
fprintf(stderr, "Unable to open config file %s.\n", filename);
} //defaults
-} //ReadConf
+}
int StartNewPiece(int scr, char shape)
{
for (i = 1; i < MAX_SCREENS; i++) if (Players[i].alive > 0)
paused |= Players[i].flags & SCF_paused;
if (paused) paused = 1;
-} //checkPaused
+}
void StartGame(void)
{ //init new game
ClearField(i);
} //reset all players
InitFields();
-} //StartGame
+}
void CheckClears(int scr)
{ //check for full lines
} //singleplayer
} //IT'S YOU
} //lines cleared
-} //CheckClears
+}
void OneGame(void)
{
void CatchInt(int sig)
{
siglongjmp(close_env, 1);
-} //CatchInt
+}
int InitiateConnection(char *hostStr, short port)
{ //connect to host
}
AddEventGen(&netGen);
return 0;
-} //InitiateConnection
+}
void HandShake(void)
{ //talk to your host
fatal("Hm, the party apparantly ended prematurely.");
}
while (event.u.net.type != NP_gamedata);
-} //HandShake
+}
MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event)
event->u.net.data = gen->buf + HEADER_SIZE3;
if (type == NP_endConn) return E_lostConn;
return E_net;
-} //NetGenFunc
+}
void SendPacket(short uid, NetPacketType type, int size, void *data)
{ //send shit to server
die("write (header)");
if (size > 0 && data && MyWrite(netGen.fd, data, size) != size)
die("write");
-} //SendPacket
+}
void CloseNet(void)
{ //kick some connection's ass!
}
if (netGen.next)
RemoveEventGen(&netGen);
-} //CloseNet
+}
/*
* vi: ts=4 ai
if (size > 0 && data && MyWrite(netGen[playa].fd, data, size) != size)
die("write");
}
-} //SendPacketTo
+}
static MyEventType AlarmGenFunc(EventGenRec *gen, MyEvent *event)
{
return E_alarm;
-} //AlarmGenFunc
+}
void SCloseNet(short playa)
{ //kick some connection's ass!
}
if (netGen[playa].next)
RemoveEventGen(&netGen[playa]);
-} //SCloseNet
+}
void CloseNets(void)
{ //nou oogjes dicht en snaveltjes toe
for (i = 1; i < MAX_SCREENS; i++)
SCloseNet(i); //bye everybuddy
fprintf(stderr, "* All Done\n\n");
-} //CloseNets
+}
MyEventType NetGenFunc(EventGenRec *gen, MyEvent *event)
{ //receive
return E_lostConn;
} //client sent quit signal
return E_net;
-} //NetGenFunc
+}
static MyEventType ConnGenFunc(EventGenRec *gen, MyEvent *event)
}
} //E_connect
return E_connect;
-} //ConnGenFunc
+}
void CountPlayers(void)
{ //count number of players/teams
} //player of same team counted before
playercount++;
} //player alive
-} //CountPlayers
+}
int StartServer(void)
{
} //game (ready to) start(ed)
} while (1);
fprintf(stderr, "* Exiting server\n");
-} //StartServer
+}
void SHeader(void)
fclose(file_out);
fprintf(stderr, "Wrote new game configuration to %s\n", CONFIG_FILE);
-} //WriteConf
+}
void HandleOption(char tag, char *value)
{
default:
break;
}
-} //HandleParam
+}
void ReadConf(char *filename)
{
fprintf(stderr, "Unable to open config file %s.\n", filename);
} //defaults
-} //ReadConf
+}
void CatchInt(int sig)
{
"NETRIS %s\t(c) 1994-1996,1999 Mark H. Weaver <mhw@netris.org>\n"
" \t(c) 2002 Shiar <shiar@shiar.org>\n\n",
version_string);
-} //Header
+}
void Usage(void)
{
"along with this program; if not, write to the Free Software\n"
"Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n"
"\n");
-} //DistInfo
+}
void Rules(void)
{
"\n"
"The longest surviving player wins the game.\n"
"\n");
-} //Rules
+}
///////////// RANDOM /////////////
{
Game.seed = seed;
myRandSeed = seed % 31751 + 1;
-} //SRandom
+}
int Random(int min, int max1)
{ //return a random value
myRandSeed = (myRandSeed * 31751 + 15437) % 32767;
return myRandSeed % (max1 - min) + min;
-} //Random
+}
///////////// I/O /////////////
return result;
}
return len;
-} //MyRead
+}
int MyWrite(int fd, void *data, int len)
{
return result;
}
return len;
-} //MyWrite
+}
///////////// TIME /////////////
{
tv->tv_sec = usec / 1000000;
tv->tv_usec = usec % 1000000;
-} //SetTimeval
+}
long GetTimeval(struct timeval *tv)
{
return tv->tv_sec * 1000000 + tv->tv_usec;
-} //GetTimeval
+}
long AbsTimeval(void)
{
gettimeofday(&tv, NULL);
return GetTimeval(&tv);
-} //CurTimeval
+}
void ResetBaseTime(void)
{ //Reset the timer
baseTimeval = AbsTimeval();
-} //ResetBaseTime
+}
void PauseTime(void)
{ //Pause the timer
baseTimeval -= AbsTimeval();
-} //PauseTime
+}
void ResumeTime(void)
{ //Unpause timer
baseTimeval += AbsTimeval();
-} //ResumeTime
+}
long CurTimeval(void)
{
gettimeofday(&tv, NULL);
return GetTimeval(&tv) - baseTimeval;
-} //CurTimeval
+}
static long SetITimer1(long interval, long value)
{
{
fprintf(stderr, "%s\n", msg);
exit(1);
-} //fatal
+}
void BlockSignals(MySigSet *saved, ...)
{
*saved = sigblock(set);
#endif
va_end(args);
-} //BlockSignals
+}
void RestoreSignals(MySigSet *saved, MySigSet *set)
{
else
sigsetmask(*set);
#endif
-} //RestoreSignals
+}
///////////// EVENTS /////////////
assert(gen->next == NULL);
gen->next = nextGen->next;
nextGen->next = gen;
-} //AddEventGen
+}
void RemoveEventGen(EventGenRec *gen)
{
nextGen->next = gen->next;
gen->next = NULL;
}
-} //RemoveEventGen
+}
MyEventType WaitMyEvent(MyEvent *event, int mask)
{ //poll
} while (gen != nextGen);
retry = 1;
}
-} //WaitMyEvent
+}
/*
* vi: ts=4 ai