Reformat all C files.

I'll push a formatting guide at some point. There may still be
outstanding changes, but please feel free to resolve those as you arrive
a them.

To the best of my knowledge, there is no changes to the actual code
content, but the formatter does have the occasional bug. If you run into
an issue, please fix it!
This commit is contained in:
Sean Hunt
2015-05-09 13:43:16 -04:00
parent 167800afdf
commit 97d6fade74
270 changed files with 182649 additions and 173878 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mhinput.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
/* NetHack 3.6 mhinput.c $NHDT-Date: 1431192786 2015/05/09 17:33:06 $ $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
/* NetHack 3.6 mhinput.c $Date: 2009/05/06 10:52:10 $ $Revision: 1.5 $ */
/* SCCS Id: @(#)mhinput.c 3.5 2005/01/23 */
/* Copyright (C) 2001 by Alex Kompel */
@@ -10,9 +10,9 @@
/* nethack input queue functions */
#define NH_INPUT_BUFFER_SIZE 64
#define NH_INPUT_BUFFER_SIZE 64
/* as it stands right now we need only one slot
/* as it stands right now we need only one slot
since events are processed almost the same time as
they occur but I like large round numbers */
@@ -22,93 +22,99 @@ static int nhi_read_pos = 0;
static int nhi_write_pos = 0;
/* initialize input queue */
void mswin_nh_input_init()
void
mswin_nh_input_init()
{
if( !nhi_init_input ) {
nhi_init_input = 1;
if (!nhi_init_input) {
nhi_init_input = 1;
ZeroMemory( nhi_input_buffer, sizeof(nhi_input_buffer) );
nhi_read_pos = 0;
nhi_write_pos = 0;
}
ZeroMemory(nhi_input_buffer, sizeof(nhi_input_buffer));
nhi_read_pos = 0;
nhi_write_pos = 0;
}
}
/* check for input */
int mswin_have_input()
int
mswin_have_input()
{
return
return
#ifdef SAFERHANGUP
/* we always have input (ESC) if hangup was requested */
program_state.done_hup ||
/* we always have input (ESC) if hangup was requested */
program_state.done_hup ||
#endif
(nhi_read_pos!=nhi_write_pos);
(nhi_read_pos != nhi_write_pos);
}
/* add event to the queue */
void mswin_input_push(PMSNHEvent event)
void
mswin_input_push(PMSNHEvent event)
{
int new_write_pos;
int new_write_pos;
if( !nhi_init_input ) mswin_nh_input_init();
if (!nhi_init_input)
mswin_nh_input_init();
new_write_pos = (nhi_write_pos+1) % NH_INPUT_BUFFER_SIZE;
if(new_write_pos!=nhi_read_pos) {
memcpy(nhi_input_buffer+nhi_write_pos, event, sizeof(*event));
nhi_write_pos = new_write_pos;
}
new_write_pos = (nhi_write_pos + 1) % NH_INPUT_BUFFER_SIZE;
if (new_write_pos != nhi_read_pos) {
memcpy(nhi_input_buffer + nhi_write_pos, event, sizeof(*event));
nhi_write_pos = new_write_pos;
}
}
/* get event from the queue and delete it */
PMSNHEvent mswin_input_pop()
PMSNHEvent
mswin_input_pop()
{
PMSNHEvent retval;
PMSNHEvent retval;
#ifdef SAFERHANGUP
/* always return ESC when hangup was requested */
if( program_state.done_hup ) {
static MSNHEvent hangup_event;
hangup_event.type = NHEVENT_CHAR;
hangup_event.kbd.ch = '\033';
return &hangup_event;
}
/* always return ESC when hangup was requested */
if (program_state.done_hup) {
static MSNHEvent hangup_event;
hangup_event.type = NHEVENT_CHAR;
hangup_event.kbd.ch = '\033';
return &hangup_event;
}
#endif
if( !nhi_init_input ) mswin_nh_input_init();
if (!nhi_init_input)
mswin_nh_input_init();
if( nhi_read_pos!=nhi_write_pos ) {
retval = &nhi_input_buffer[nhi_read_pos];
nhi_read_pos = (nhi_read_pos+1) % NH_INPUT_BUFFER_SIZE;
} else {
retval = NULL;
}
if (nhi_read_pos != nhi_write_pos) {
retval = &nhi_input_buffer[nhi_read_pos];
nhi_read_pos = (nhi_read_pos + 1) % NH_INPUT_BUFFER_SIZE;
} else {
retval = NULL;
}
return retval;
return retval;
}
/* get event from the queue but leave it there */
PMSNHEvent mswin_input_peek()
PMSNHEvent
mswin_input_peek()
{
PMSNHEvent retval;
PMSNHEvent retval;
#ifdef SAFERHANGUP
/* always return ESC when hangup was requested */
if( program_state.done_hup ) {
static MSNHEvent hangup_event;
hangup_event.type = NHEVENT_CHAR;
hangup_event.kbd.ch = '\033';
return &hangup_event;
}
/* always return ESC when hangup was requested */
if (program_state.done_hup) {
static MSNHEvent hangup_event;
hangup_event.type = NHEVENT_CHAR;
hangup_event.kbd.ch = '\033';
return &hangup_event;
}
#endif
if( !nhi_init_input ) mswin_nh_input_init();
if (!nhi_init_input)
mswin_nh_input_init();
if( nhi_read_pos!=nhi_write_pos ) {
retval = &nhi_input_buffer[nhi_read_pos];
} else {
retval = NULL;
}
return retval;
if (nhi_read_pos != nhi_write_pos) {
retval = &nhi_input_buffer[nhi_read_pos];
} else {
retval = NULL;
}
return retval;
}