add clang-format config and format everything
This commit is contained in:
parent
187ec1a68e
commit
56458af5fc
29
.clang-format
Normal file
29
.clang-format
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
BasedOnStyle: LLVM
|
||||
IndentWidth: 4
|
||||
TabWidth: 4
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
AlignOperands: false
|
||||
AlignTrailingComments: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakTemplateDeclarations: true
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BreakConstructorInitializersBeforeComma: true
|
||||
ColumnLimit: 160
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 0
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: All
|
||||
PointerAlignment: Left
|
||||
SpaceAfterCStyleCast: true
|
||||
Standard: Cpp11
|
||||
UseTab: Always
|
||||
...
|
198
src/announce.c
198
src/announce.c
@ -2,12 +2,12 @@
|
||||
#include "announce.h"
|
||||
#include "network.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <avahi-client/client.h>
|
||||
#include <avahi-client/lookup.h>
|
||||
@ -20,10 +20,10 @@
|
||||
|
||||
#define SERVICE_TYPE "_sdlbomber._udp"
|
||||
|
||||
static AvahiClient *client = NULL;
|
||||
static AvahiThreadedPoll *threaded_poll = NULL;
|
||||
static AvahiEntryGroup *group = NULL;
|
||||
static AvahiServiceBrowser *browser = NULL;
|
||||
static AvahiClient* client = NULL;
|
||||
static AvahiThreadedPoll* threaded_poll = NULL;
|
||||
static AvahiEntryGroup* group = NULL;
|
||||
static AvahiServiceBrowser* browser = NULL;
|
||||
|
||||
static char* name = NULL;
|
||||
|
||||
@ -37,32 +37,31 @@ static char buffer_glchanged[10];
|
||||
gamelistentry gamelistentries[10];
|
||||
int gamelistsize = 0;
|
||||
|
||||
static void myerror(AvahiClient *c, const char *s) {
|
||||
static void myerror(AvahiClient* c, const char* s) {
|
||||
fprintf(stderr, "Error in: %s\n (%s)", s, avahi_strerror(avahi_client_errno(c)));
|
||||
}
|
||||
|
||||
static void create_services(AvahiClient *c);
|
||||
static void create_services(AvahiClient* c);
|
||||
|
||||
static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata) {
|
||||
static void entry_group_callback(AvahiEntryGroup* g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void* userdata) {
|
||||
group = g;
|
||||
|
||||
switch (state) {
|
||||
case AVAHI_ENTRY_GROUP_ESTABLISHED :
|
||||
case AVAHI_ENTRY_GROUP_ESTABLISHED:
|
||||
break;
|
||||
|
||||
case AVAHI_ENTRY_GROUP_COLLISION :
|
||||
{
|
||||
char *n = avahi_alternative_service_name(name);
|
||||
avahi_free(name);
|
||||
name = n;
|
||||
}
|
||||
case AVAHI_ENTRY_GROUP_COLLISION: {
|
||||
char* n = avahi_alternative_service_name(name);
|
||||
avahi_free(name);
|
||||
name = n;
|
||||
}
|
||||
|
||||
/* And recreate the services */
|
||||
avahi_entry_group_reset(group);
|
||||
create_services(avahi_entry_group_get_client(g));
|
||||
break;
|
||||
|
||||
case AVAHI_ENTRY_GROUP_FAILURE :
|
||||
case AVAHI_ENTRY_GROUP_FAILURE:
|
||||
fprintf(stderr, "Entry group failure: %s\n", avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g))));
|
||||
|
||||
avahi_threaded_poll_quit(threaded_poll);
|
||||
@ -74,7 +73,7 @@ static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state,
|
||||
}
|
||||
}
|
||||
|
||||
static void create_services(AvahiClient *c) {
|
||||
static void create_services(AvahiClient* c) {
|
||||
int ret;
|
||||
|
||||
if (!group) {
|
||||
@ -90,10 +89,9 @@ again:
|
||||
snprintf(buf_version, sizeof(buf_version), "version=%X", (unsigned int) version);
|
||||
if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, name, SERVICE_TYPE, NULL, NULL, port, buf_version, NULL)) < 0) {
|
||||
|
||||
if (ret == AVAHI_ERR_COLLISION)
|
||||
goto collision;
|
||||
if (ret == AVAHI_ERR_COLLISION) goto collision;
|
||||
|
||||
fprintf(stderr, "Failed to add "SERVICE_TYPE": %s\n", avahi_strerror(ret));
|
||||
fprintf(stderr, "Failed to add " SERVICE_TYPE ": %s\n", avahi_strerror(ret));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -105,12 +103,11 @@ again:
|
||||
|
||||
return;
|
||||
|
||||
collision:
|
||||
{
|
||||
char *n = avahi_alternative_service_name(name);
|
||||
avahi_free(name);
|
||||
name = n;
|
||||
}
|
||||
collision : {
|
||||
char* n = avahi_alternative_service_name(name);
|
||||
avahi_free(name);
|
||||
name = n;
|
||||
}
|
||||
avahi_entry_group_reset(group);
|
||||
goto again;
|
||||
|
||||
@ -118,8 +115,8 @@ fail:
|
||||
avahi_threaded_poll_quit(threaded_poll);
|
||||
}
|
||||
|
||||
static void client_callback(AvahiClient *c, AvahiClientState state, void * userdata) {
|
||||
(void)userdata;
|
||||
static void client_callback(AvahiClient* c, AvahiClientState state, void* userdata) {
|
||||
(void) userdata;
|
||||
|
||||
client = c;
|
||||
switch (state) {
|
||||
@ -132,16 +129,14 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void * userd
|
||||
break;
|
||||
case AVAHI_CLIENT_S_COLLISION:
|
||||
case AVAHI_CLIENT_S_REGISTERING:
|
||||
if (group) {
|
||||
avahi_entry_group_reset(group);
|
||||
}
|
||||
if (group) { avahi_entry_group_reset(group); }
|
||||
break;
|
||||
case AVAHI_CLIENT_CONNECTING:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int registergame(const char *playername, uint16_t p, const unsigned char v[4]) {
|
||||
int registergame(const char* playername, uint16_t p, const unsigned char v[4]) {
|
||||
if (name) avahi_free(name);
|
||||
name = avahi_strdup(playername);
|
||||
|
||||
@ -165,7 +160,7 @@ void unregistergame(void) {
|
||||
avahi_threaded_poll_unlock(threaded_poll);
|
||||
}
|
||||
|
||||
static void remove_game_with_name(const char *name) {
|
||||
static void remove_game_with_name(const char* name) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < buffer_glsize; i++) {
|
||||
@ -180,15 +175,26 @@ static void remove_game_with_name(const char *name) {
|
||||
}
|
||||
}
|
||||
|
||||
static void resolve_callback(AvahiServiceResolver *r, AvahiIfIndex interface, AvahiProtocol protocol, AvahiResolverEvent event,
|
||||
const char *name, const char *type, const char *domain, const char *host_name, const AvahiAddress *address,
|
||||
uint16_t port, AvahiStringList *txt, AvahiLookupResultFlags flags, void* userdata) {
|
||||
static void resolve_callback(
|
||||
AvahiServiceResolver* r,
|
||||
AvahiIfIndex interface,
|
||||
AvahiProtocol protocol,
|
||||
AvahiResolverEvent event,
|
||||
const char* name,
|
||||
const char* type,
|
||||
const char* domain,
|
||||
const char* host_name,
|
||||
const AvahiAddress* address,
|
||||
uint16_t port,
|
||||
AvahiStringList* txt,
|
||||
AvahiLookupResultFlags flags,
|
||||
void* userdata) {
|
||||
int i;
|
||||
uint32_t want_version;
|
||||
(void)interface;
|
||||
(void)host_name;
|
||||
(void)flags;
|
||||
(void)userdata;
|
||||
(void) interface;
|
||||
(void) host_name;
|
||||
(void) flags;
|
||||
(void) userdata;
|
||||
assert(r);
|
||||
|
||||
if (protocol != AVAHI_PROTO_INET) goto done; /* ignore non IPv4 for now */
|
||||
@ -200,75 +206,89 @@ static void resolve_callback(AvahiServiceResolver *r, AvahiIfIndex interface, Av
|
||||
/* Called whenever a service has been resolved successfully or timed out */
|
||||
|
||||
switch (event) {
|
||||
case AVAHI_RESOLVER_FAILURE:
|
||||
fprintf(stderr, "(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", name, type, domain, avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r))));
|
||||
break;
|
||||
case AVAHI_RESOLVER_FAILURE:
|
||||
fprintf(
|
||||
stderr,
|
||||
"(Resolver) Failed to resolve service '%s' of type '%s' in domain '%s': %s\n",
|
||||
name,
|
||||
type,
|
||||
domain,
|
||||
avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r))));
|
||||
break;
|
||||
|
||||
case AVAHI_RESOLVER_FOUND: {
|
||||
gamelistentry *ge;
|
||||
unsigned int version;
|
||||
int have_version = 0;
|
||||
AvahiStringList *psl;
|
||||
for (psl = txt ; psl ; psl = psl->next) {
|
||||
if (0 == strncmp("version=", (const char*) psl->text, 8)) {
|
||||
sscanf((const char*) psl->text, "version=%X", &version);
|
||||
if (version != want_version) goto done; /* version mismatch */
|
||||
have_version = 1;
|
||||
}
|
||||
case AVAHI_RESOLVER_FOUND: {
|
||||
gamelistentry* ge;
|
||||
unsigned int version;
|
||||
int have_version = 0;
|
||||
AvahiStringList* psl;
|
||||
for (psl = txt; psl; psl = psl->next) {
|
||||
if (0 == strncmp("version=", (const char*) psl->text, 8)) {
|
||||
sscanf((const char*) psl->text, "version=%X", &version);
|
||||
if (version != want_version) goto done; /* version mismatch */
|
||||
have_version = 1;
|
||||
}
|
||||
if (!have_version) goto done;
|
||||
remove_game_with_name(name);
|
||||
i = buffer_glsize++;
|
||||
ge = &buffer_glentries[i];
|
||||
buffer_glchanged[i] = 1;
|
||||
memset(ge, 0, sizeof(*ge));
|
||||
ge->netname.sin_addr.s_addr = address->data.ipv4.address;
|
||||
ge->netname.sin_family = AF_INET;
|
||||
ge->netname.sin_port = port;
|
||||
strncpy(ge->name, name, 15);
|
||||
}
|
||||
if (!have_version) goto done;
|
||||
remove_game_with_name(name);
|
||||
i = buffer_glsize++;
|
||||
ge = &buffer_glentries[i];
|
||||
buffer_glchanged[i] = 1;
|
||||
memset(ge, 0, sizeof(*ge));
|
||||
ge->netname.sin_addr.s_addr = address->data.ipv4.address;
|
||||
ge->netname.sin_family = AF_INET;
|
||||
ge->netname.sin_port = port;
|
||||
strncpy(ge->name, name, 15);
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
avahi_service_resolver_free(r);
|
||||
}
|
||||
|
||||
static void browse_callback(AvahiServiceBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event,
|
||||
const char *name, const char *type, const char *domain, AvahiLookupResultFlags flags, void* userdata) {
|
||||
(void)flags;
|
||||
static void browse_callback(
|
||||
AvahiServiceBrowser* b,
|
||||
AvahiIfIndex interface,
|
||||
AvahiProtocol protocol,
|
||||
AvahiBrowserEvent event,
|
||||
const char* name,
|
||||
const char* type,
|
||||
const char* domain,
|
||||
AvahiLookupResultFlags flags,
|
||||
void* userdata) {
|
||||
(void) flags;
|
||||
|
||||
assert(b);
|
||||
|
||||
/* Called whenever a new services becomes available on the LAN or is removed from the LAN */
|
||||
|
||||
switch (event) {
|
||||
case AVAHI_BROWSER_FAILURE:
|
||||
case AVAHI_BROWSER_FAILURE:
|
||||
|
||||
fprintf(stderr, "(Browser) %s\n", avahi_strerror(avahi_client_errno(client)));
|
||||
avahi_threaded_poll_quit(threaded_poll);
|
||||
return;
|
||||
fprintf(stderr, "(Browser) %s\n", avahi_strerror(avahi_client_errno(client)));
|
||||
avahi_threaded_poll_quit(threaded_poll);
|
||||
return;
|
||||
|
||||
case AVAHI_BROWSER_NEW:
|
||||
/* fprintf(stderr, "(Browser) NEW: service '%s' of type '%s' in domain '%s'\n", name, type, domain); */
|
||||
case AVAHI_BROWSER_NEW:
|
||||
/* fprintf(stderr, "(Browser) NEW: service '%s' of type '%s' in domain '%s'\n", name, type, domain); */
|
||||
|
||||
/* We ignore the returned resolver object. In the callback
|
||||
function we free it. If the server is terminated before
|
||||
the callback function is called the server will free
|
||||
the resolver for us. */
|
||||
/* We ignore the returned resolver object. In the callback
|
||||
function we free it. If the server is terminated before
|
||||
the callback function is called the server will free
|
||||
the resolver for us. */
|
||||
|
||||
if (!(avahi_service_resolver_new(client, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, resolve_callback, userdata)))
|
||||
fprintf(stderr, "Failed to resolve service '%s': %s\n", name, avahi_strerror(avahi_client_errno(client)));
|
||||
if (!(avahi_service_resolver_new(client, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, resolve_callback, userdata)))
|
||||
fprintf(stderr, "Failed to resolve service '%s': %s\n", name, avahi_strerror(avahi_client_errno(client)));
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case AVAHI_BROWSER_REMOVE:
|
||||
remove_game_with_name(name);
|
||||
break;
|
||||
case AVAHI_BROWSER_REMOVE:
|
||||
remove_game_with_name(name);
|
||||
break;
|
||||
|
||||
case AVAHI_BROWSER_ALL_FOR_NOW:
|
||||
break;
|
||||
case AVAHI_BROWSER_CACHE_EXHAUSTED:
|
||||
break;
|
||||
case AVAHI_BROWSER_ALL_FOR_NOW:
|
||||
break;
|
||||
case AVAHI_BROWSER_CACHE_EXHAUSTED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ struct gamelistentry {
|
||||
char name[16];
|
||||
};
|
||||
|
||||
int registergame(const char *playername, uint16_t port, const unsigned char version[4]);
|
||||
int registergame(const char* playername, uint16_t port, const unsigned char version[4]);
|
||||
void unregistergame(void);
|
||||
|
||||
int searchgames(void);
|
||||
|
34
src/bomber.c
34
src/bomber.c
@ -1,31 +1,31 @@
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "bomber.h"
|
||||
#include "gfx.h"
|
||||
#include "announce.h"
|
||||
#include "sound.h"
|
||||
#include "menu.h"
|
||||
#include "utils.h"
|
||||
#include "network.h"
|
||||
#include "game.h"
|
||||
#include "bomber.h"
|
||||
#include "draw.h"
|
||||
#include "game.h"
|
||||
#include "gfx.h"
|
||||
#include "menu.h"
|
||||
#include "network.h"
|
||||
#include "sound.h"
|
||||
#include "utils.h"
|
||||
|
||||
int main(void) {
|
||||
char *p;
|
||||
char* p;
|
||||
|
||||
strcpy(playername,"ANONYMOUS");
|
||||
p=getenv("USER");
|
||||
if(p) strncpy(playername,p,sizeof(playername)-1);
|
||||
strcpy(playername, "ANONYMOUS");
|
||||
p = getenv("USER");
|
||||
if (p) strncpy(playername, p, sizeof(playername) - 1);
|
||||
|
||||
create_seed_unique();
|
||||
|
||||
|
75
src/bomber.h
75
src/bomber.h
@ -1,7 +1,8 @@
|
||||
#ifndef BOMBER_H
|
||||
#define BOMBER_H
|
||||
|
||||
#include "SDL.h"
|
||||
#include "list.h"
|
||||
#include <SDL.h>
|
||||
|
||||
typedef unsigned char uchar;
|
||||
extern int xcolors[256];
|
||||
@ -38,30 +39,25 @@ extern int xcolors[256];
|
||||
typedef struct gfxset {
|
||||
uchar gs_colormap[768];
|
||||
uchar gs_inout[256];
|
||||
uchar *gs_pic;
|
||||
uchar* gs_pic;
|
||||
int gs_xsize;
|
||||
int gs_ysize;
|
||||
} gfxset;
|
||||
|
||||
typedef struct figure {
|
||||
int xsize,ysize;
|
||||
int xdelta,ydelta;
|
||||
uchar *graphics;
|
||||
int xsize, ysize;
|
||||
int xdelta, ydelta;
|
||||
uchar* graphics;
|
||||
} figure;
|
||||
|
||||
typedef struct solid {
|
||||
int xsize,ysize;
|
||||
uchar *graphics;
|
||||
int xsize, ysize;
|
||||
uchar* graphics;
|
||||
} solid;
|
||||
|
||||
typedef struct listhead listhead;
|
||||
struct listhead {
|
||||
listhead *prev, *next;
|
||||
};
|
||||
|
||||
typedef struct player {
|
||||
listhead list, list_all_players;
|
||||
int xpos,ypos;
|
||||
int xpos, ypos;
|
||||
int flags;
|
||||
int abilities;
|
||||
int speed;
|
||||
@ -69,15 +65,15 @@ typedef struct player {
|
||||
int bombsused;
|
||||
int bombsavailable;
|
||||
int flamelength;
|
||||
int *at;
|
||||
int* at;
|
||||
int figcount;
|
||||
int doing;
|
||||
int action;
|
||||
int color;
|
||||
int controller;
|
||||
int fixx,fixy;
|
||||
int fixx, fixy;
|
||||
int kills, deaths;
|
||||
figure *figure;
|
||||
figure* figure;
|
||||
} player;
|
||||
|
||||
#define FLG_CONTROL 1
|
||||
@ -85,25 +81,25 @@ typedef struct player {
|
||||
|
||||
|
||||
typedef struct sprite {
|
||||
int flags;
|
||||
int xpos,ypos;
|
||||
figure *fig;
|
||||
int flags;
|
||||
int xpos, ypos;
|
||||
figure* fig;
|
||||
} sprite;
|
||||
|
||||
typedef struct damage {
|
||||
int xpos,ypos;
|
||||
int xsize,ysize;
|
||||
int xpos, ypos;
|
||||
int xsize, ysize;
|
||||
} damage;
|
||||
|
||||
typedef struct bomb {
|
||||
listhead list;
|
||||
int type;
|
||||
int xpos,ypos;
|
||||
int px,py;
|
||||
int xpos, ypos;
|
||||
int px, py;
|
||||
int power;
|
||||
int timer;
|
||||
int figcount;
|
||||
player *owner;
|
||||
player* owner;
|
||||
} bomb;
|
||||
|
||||
|
||||
@ -117,11 +113,11 @@ typedef struct bomb {
|
||||
|
||||
typedef struct flame {
|
||||
listhead list;
|
||||
int xpos,ypos;
|
||||
int px,py;
|
||||
int xpos, ypos;
|
||||
int px, py;
|
||||
int timer;
|
||||
int lurd;
|
||||
player *owner;
|
||||
player* owner;
|
||||
} flame;
|
||||
|
||||
#define FL_UP 2
|
||||
@ -131,27 +127,27 @@ typedef struct flame {
|
||||
|
||||
typedef struct brickdecay {
|
||||
listhead list;
|
||||
int xpos,ypos;
|
||||
int px,py;
|
||||
int xpos, ypos;
|
||||
int px, py;
|
||||
int timer;
|
||||
} brickdecay;
|
||||
|
||||
typedef struct bonustile {
|
||||
listhead list;
|
||||
int xpos,ypos;
|
||||
int px,py;
|
||||
int xpos, ypos;
|
||||
int px, py;
|
||||
int type;
|
||||
} bonustile;
|
||||
|
||||
typedef struct generic {
|
||||
listhead list;
|
||||
int xpos,ypos;
|
||||
int px,py;
|
||||
int xpos, ypos;
|
||||
int px, py;
|
||||
int timer;
|
||||
void (*process)();
|
||||
void (*draw)();
|
||||
void *ptr1,*ptr2;
|
||||
int data1,data2;
|
||||
void *ptr1, *ptr2;
|
||||
int data1, data2;
|
||||
} generic;
|
||||
|
||||
enum tile_types {
|
||||
@ -175,10 +171,10 @@ enum tile_types {
|
||||
|
||||
|
||||
// #define ACT_INVALID 0x88
|
||||
#define ACT_NONE 0
|
||||
#define ACT_UP 1
|
||||
#define ACT_DOWN 2
|
||||
#define ACT_LEFT 3
|
||||
#define ACT_NONE 0
|
||||
#define ACT_UP 1
|
||||
#define ACT_DOWN 2
|
||||
#define ACT_LEFT 3
|
||||
#define ACT_RIGHT 4
|
||||
#define ACT_ENTER 5
|
||||
#define ACT_QUIT 6
|
||||
@ -200,7 +196,6 @@ enum tile_types {
|
||||
#define CODE_ALLDEAD 2
|
||||
|
||||
|
||||
|
||||
#define MAXTHINGS 500
|
||||
#define MAXSETS 8
|
||||
#define MAXSPRITES 256
|
||||
|
446
src/draw.c
446
src/draw.c
@ -1,15 +1,15 @@
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "bomber.h"
|
||||
#include "draw.h"
|
||||
@ -48,191 +48,206 @@ figure flamefigs[MAXSETS][NUMFLAMEFRAMES];
|
||||
figure tiles[15];
|
||||
figure death[NUMDEATHFRAMES];
|
||||
|
||||
int fontxsize,fontysize;
|
||||
int bigfontxsize,bigfontysize,bigfontyspace;
|
||||
int fontxsize, fontysize;
|
||||
int bigfontxsize, bigfontysize, bigfontyspace;
|
||||
|
||||
static int textx,texty;
|
||||
static int textx, texty;
|
||||
|
||||
static const unsigned char *remapstring = (const unsigned char*) "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.:!?\177/\\*-,>< =";
|
||||
static const unsigned char* remapstring = (const unsigned char*) "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.:!?\177/\\*-,>< =";
|
||||
static char asciiremap[256];
|
||||
|
||||
/* On screen array variables */
|
||||
int arraynumx=15;
|
||||
int arraynumy=11;
|
||||
int arraystartx=20;
|
||||
int arraystarty=70;
|
||||
int arrayspacex=40;
|
||||
int arrayspacey=36;
|
||||
int arraynumx = 15;
|
||||
int arraynumy = 11;
|
||||
int arraystartx = 20;
|
||||
int arraystarty = 70;
|
||||
int arrayspacex = 40;
|
||||
int arrayspacey = 36;
|
||||
|
||||
static sprite sprites[MAXSPRITES];
|
||||
static int spritesused=0;
|
||||
static int spritesused = 0;
|
||||
|
||||
#define IBUFFLEN 1024
|
||||
int ileft=0,ihand=0,byteswide;
|
||||
unsigned char ibuff[IBUFFLEN],*itake;
|
||||
int ileft = 0, ihand = 0, byteswide;
|
||||
unsigned char ibuff[IBUFFLEN], *itake;
|
||||
|
||||
static void freegfxset(gfxset *gs) {
|
||||
if(gs->gs_pic) free(gs->gs_pic);
|
||||
gs->gs_pic=0;
|
||||
static void freegfxset(gfxset* gs) {
|
||||
if (gs->gs_pic) free(gs->gs_pic);
|
||||
gs->gs_pic = 0;
|
||||
}
|
||||
|
||||
static int myci() {
|
||||
if (!ileft) {
|
||||
ileft=read(ihand,ibuff,IBUFFLEN);
|
||||
ileft = read(ihand, ibuff, IBUFFLEN);
|
||||
|
||||
if(!ileft) return -1;
|
||||
itake=ibuff;
|
||||
if (!ileft) return -1;
|
||||
itake = ibuff;
|
||||
}
|
||||
ileft--;
|
||||
return *itake++;
|
||||
}
|
||||
|
||||
static int dopcxreal(char *name,gfxset *gs) {
|
||||
int xs,ys;
|
||||
int i,j,k;
|
||||
static int dopcxreal(char* name, gfxset* gs) {
|
||||
int xs, ys;
|
||||
int i, j, k;
|
||||
int totalsize;
|
||||
int width,height;
|
||||
unsigned char *bm,*lp;
|
||||
int width, height;
|
||||
unsigned char *bm, *lp;
|
||||
char tname[256];
|
||||
|
||||
memset(gs,0,sizeof(gfxset));
|
||||
ileft=0;
|
||||
snprintf(tname,sizeof(tname),DATADIR "/%s",name);
|
||||
ihand=open(tname,O_RDONLY);
|
||||
if(ihand<0) {
|
||||
memset(gs, 0, sizeof(gfxset));
|
||||
ileft = 0;
|
||||
snprintf(tname, sizeof(tname), DATADIR "/%s", name);
|
||||
ihand = open(tname, O_RDONLY);
|
||||
if (ihand < 0) {
|
||||
char tname2[260];
|
||||
snprintf(tname2,sizeof(tname2),"%s.pcx",tname);
|
||||
ihand=open(tname2,O_RDONLY);
|
||||
if(ihand<0)
|
||||
return 1;
|
||||
snprintf(tname2, sizeof(tname2), "%s.pcx", tname);
|
||||
ihand = open(tname2, O_RDONLY);
|
||||
if (ihand < 0) return 1;
|
||||
}
|
||||
if(myci()!=10) {close(ihand);return 2;} // 10=zsoft .pcx
|
||||
if(myci()!=5) {close(ihand);return 3;} // version 3.0
|
||||
if(myci()!=1) {close(ihand);return 4;} //encoding method
|
||||
if(myci()!=8) {close(ihand);return 5;} //bpp
|
||||
xs=myci();
|
||||
xs|=myci()<<8;
|
||||
ys=myci();
|
||||
ys|=myci()<<8;
|
||||
width=myci();
|
||||
width|=myci()<<8;
|
||||
height=myci();
|
||||
height|=myci()<<8;
|
||||
width=width+1-xs;
|
||||
height=height+1-ys;
|
||||
for(i=0;i<48+4;++i) myci();
|
||||
if (myci() != 10) {
|
||||
close(ihand);
|
||||
return 2;
|
||||
} // 10=zsoft .pcx
|
||||
if (myci() != 5) {
|
||||
close(ihand);
|
||||
return 3;
|
||||
} // version 3.0
|
||||
if (myci() != 1) {
|
||||
close(ihand);
|
||||
return 4;
|
||||
} // encoding method
|
||||
if (myci() != 8) {
|
||||
close(ihand);
|
||||
return 5;
|
||||
} // bpp
|
||||
xs = myci();
|
||||
xs |= myci() << 8;
|
||||
ys = myci();
|
||||
ys |= myci() << 8;
|
||||
width = myci();
|
||||
width |= myci() << 8;
|
||||
height = myci();
|
||||
height |= myci() << 8;
|
||||
width = width + 1 - xs;
|
||||
height = height + 1 - ys;
|
||||
for (i = 0; i < 48 + 4; ++i) myci();
|
||||
myci();
|
||||
if(myci()!=1) {close(ihand);return 6;} // # of planes
|
||||
byteswide=myci();
|
||||
byteswide|=myci()<<8;
|
||||
i=myci();
|
||||
i|=myci()<<8;
|
||||
// if(i!=1) {close(ihand);return 7;} // 1=color/bw,2=grey
|
||||
for(i=0;i<58;++i) myci();
|
||||
totalsize=height*byteswide;
|
||||
bm=malloc(totalsize+1);
|
||||
if(!bm) {close(ihand);return 8;} // no memory
|
||||
gs->gs_pic=bm;
|
||||
gs->gs_xsize=width;
|
||||
gs->gs_ysize=height;
|
||||
while(height--) {
|
||||
lp=bm;
|
||||
i=byteswide;
|
||||
while(i>0) {
|
||||
j=myci();
|
||||
if(j<0xc0) {
|
||||
*lp++=j;
|
||||
if (myci() != 1) {
|
||||
close(ihand);
|
||||
return 6;
|
||||
} // # of planes
|
||||
byteswide = myci();
|
||||
byteswide |= myci() << 8;
|
||||
i = myci();
|
||||
i |= myci() << 8;
|
||||
// if(i!=1) {close(ihand);return 7;} // 1=color/bw,2=grey
|
||||
for (i = 0; i < 58; ++i) myci();
|
||||
totalsize = height * byteswide;
|
||||
bm = malloc(totalsize + 1);
|
||||
if (!bm) {
|
||||
close(ihand);
|
||||
return 8;
|
||||
} // no memory
|
||||
gs->gs_pic = bm;
|
||||
gs->gs_xsize = width;
|
||||
gs->gs_ysize = height;
|
||||
while (height--) {
|
||||
lp = bm;
|
||||
i = byteswide;
|
||||
while (i > 0) {
|
||||
j = myci();
|
||||
if (j < 0xc0) {
|
||||
*lp++ = j;
|
||||
--i;
|
||||
} else {
|
||||
j&=0x3f;
|
||||
k=myci();
|
||||
while(j-- && i) {
|
||||
*lp++=k;
|
||||
j &= 0x3f;
|
||||
k = myci();
|
||||
while (j-- && i) {
|
||||
*lp++ = k;
|
||||
--i;
|
||||
}
|
||||
}
|
||||
}
|
||||
bm+=width;
|
||||
bm += width;
|
||||
}
|
||||
lseek(ihand,-0x300,SEEK_END);
|
||||
read(ihand,gs->gs_colormap,0x300);
|
||||
lseek(ihand, -0x300, SEEK_END);
|
||||
read(ihand, gs->gs_colormap, 0x300);
|
||||
close(ihand);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dopcx(char *name,gfxset *gs) {
|
||||
static int dopcx(char* name, gfxset* gs) {
|
||||
int err;
|
||||
|
||||
err=dopcxreal(name,gs);
|
||||
if(err)
|
||||
printf("Error loading \"%s\":code %d\n",name,err);
|
||||
err = dopcxreal(name, gs);
|
||||
if (err) printf("Error loading \"%s\":code %d\n", name, err);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void getgroup(char *name,gfxset *colorgs,figure *fig,int count) {
|
||||
static void getgroup(char* name, gfxset* colorgs, figure* fig, int count) {
|
||||
int err;
|
||||
int i;
|
||||
gfxset gs;
|
||||
|
||||
err=dopcx(name,&gs);
|
||||
if(err) exit(1000+err);
|
||||
err = dopcx(name, &gs);
|
||||
if (err) exit(1000 + err);
|
||||
createinout(&gs);
|
||||
for(i=0;i<MAXSETS;++i,fig+=count,++colorgs) {
|
||||
if(!colorgs->gs_pic) continue;
|
||||
memmove(gs.gs_colormap,colorgs->gs_colormap,
|
||||
sizeof(gs.gs_colormap));
|
||||
for (i = 0; i < MAXSETS; ++i, fig += count, ++colorgs) {
|
||||
if (!colorgs->gs_pic) continue;
|
||||
memmove(gs.gs_colormap, colorgs->gs_colormap, sizeof(gs.gs_colormap));
|
||||
createinout(&gs);
|
||||
gfxfetch(&gs,fig,count);
|
||||
gfxfetch(&gs, fig, count);
|
||||
}
|
||||
freegfxset(&gs);
|
||||
}
|
||||
|
||||
static void getsingle(char *name,figure *fig,int count) {
|
||||
static void getsingle(char* name, figure* fig, int count) {
|
||||
gfxset gs;
|
||||
int err;
|
||||
|
||||
err=dopcx(name,&gs);
|
||||
if(err) exit(1000+err);
|
||||
err = dopcx(name, &gs);
|
||||
if (err) exit(1000 + err);
|
||||
createinout(&gs);
|
||||
gfxfetch(&gs,fig,count);
|
||||
gfxfetch(&gs, fig, count);
|
||||
freegfxset(&gs);
|
||||
}
|
||||
|
||||
static void texthome(void) {
|
||||
textx=texty=10;
|
||||
textx = texty = 10;
|
||||
}
|
||||
|
||||
void drawstring(int xpos, int ypos, const char *str) {
|
||||
void drawstring(int xpos, int ypos, const char* str) {
|
||||
char ch;
|
||||
|
||||
while((ch=*str++)) {
|
||||
drawfigure(xpos,ypos,font+asciiremap[toupper(ch)]);
|
||||
xpos+=fontxsize;
|
||||
while ((ch = *str++)) {
|
||||
drawfigure(xpos, ypos, font + asciiremap[toupper(ch)]);
|
||||
xpos += fontxsize;
|
||||
}
|
||||
}
|
||||
|
||||
void drawbigstring(int xpos, int ypos, const char *str) {
|
||||
void drawbigstring(int xpos, int ypos, const char* str) {
|
||||
char ch;
|
||||
|
||||
while('\0' != (ch=*str++)) {
|
||||
drawfigure(xpos,ypos,bigfont+asciiremap[toupper(ch)]);
|
||||
xpos+=bigfontxsize;
|
||||
while ('\0' != (ch = *str++)) {
|
||||
drawfigure(xpos, ypos, bigfont + asciiremap[toupper(ch)]);
|
||||
xpos += bigfontxsize;
|
||||
}
|
||||
}
|
||||
|
||||
void centerbig(int y, const char *str) {
|
||||
void centerbig(int y, const char* str) {
|
||||
int w;
|
||||
|
||||
w=strlen(str)*bigfontxsize;
|
||||
drawbigstring((IXSIZE-w)>>1,y,str);
|
||||
w = strlen(str) * bigfontxsize;
|
||||
drawbigstring((IXSIZE - w) >> 1, y, str);
|
||||
}
|
||||
|
||||
// static void scrprintf(char *str,...) {
|
||||
// char output[256],*p,*p2;
|
||||
// va_list ap;
|
||||
//
|
||||
//
|
||||
// va_start(ap, str);
|
||||
//
|
||||
//
|
||||
// vsprintf(output,str,ap);
|
||||
// p=output;
|
||||
// for(;;) {
|
||||
@ -253,201 +268,196 @@ void centerbig(int y, const char *str) {
|
||||
// copyup();
|
||||
// }
|
||||
|
||||
static void bigscrprintf(char *str,...) {
|
||||
char output[256],*p,*p2;
|
||||
static void bigscrprintf(char* str, ...) {
|
||||
char output[256], *p, *p2;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, str);
|
||||
vsnprintf(output,sizeof(output),str,ap);
|
||||
p=output;
|
||||
for(;;) {
|
||||
p2=p;
|
||||
while(*p2 && *p2!='\n') ++p2;
|
||||
if(*p2) {
|
||||
*p2=0;
|
||||
drawbigstring(textx,texty,p);
|
||||
texty+=bigfontysize;
|
||||
textx=10;
|
||||
p=p2+1;
|
||||
vsnprintf(output, sizeof(output), str, ap);
|
||||
p = output;
|
||||
for (;;) {
|
||||
p2 = p;
|
||||
while (*p2 && *p2 != '\n') ++p2;
|
||||
if (*p2) {
|
||||
*p2 = 0;
|
||||
drawbigstring(textx, texty, p);
|
||||
texty += bigfontysize;
|
||||
textx = 10;
|
||||
p = p2 + 1;
|
||||
} else {
|
||||
drawbigstring(textx,texty,p);
|
||||
textx+=bigfontxsize*(p2-p);
|
||||
drawbigstring(textx, texty, p);
|
||||
textx += bigfontxsize * (p2 - p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
copyup();
|
||||
}
|
||||
|
||||
void addsprite(int x,int y,figure *fig) {
|
||||
sprite *sp;
|
||||
void addsprite(int x, int y, figure* fig) {
|
||||
sprite* sp;
|
||||
|
||||
if(spritesused==MAXSPRITES) return;
|
||||
sp=sprites+spritesused++;
|
||||
sp->flags=0;
|
||||
sp->xpos=x;
|
||||
sp->ypos=y;
|
||||
sp->fig=fig;
|
||||
if (spritesused == MAXSPRITES) return;
|
||||
sp = sprites + spritesused++;
|
||||
sp->flags = 0;
|
||||
sp->xpos = x;
|
||||
sp->ypos = y;
|
||||
sp->fig = fig;
|
||||
}
|
||||
|
||||
void plotsprites(void) {
|
||||
int i;
|
||||
sprite *sp;
|
||||
sprite* sp;
|
||||
|
||||
sp=sprites;
|
||||
for(i=0;i<spritesused;++i) {
|
||||
drawfigure(sp->xpos,sp->ypos,sp->fig);
|
||||
sp = sprites;
|
||||
for (i = 0; i < spritesused; ++i) {
|
||||
drawfigure(sp->xpos, sp->ypos, sp->fig);
|
||||
++sp;
|
||||
}
|
||||
}
|
||||
|
||||
void erasesprites(void) {
|
||||
int i;
|
||||
sprite *sp;
|
||||
figure *fig;
|
||||
sprite* sp;
|
||||
figure* fig;
|
||||
|
||||
sp=sprites;
|
||||
for(i=0;i<spritesused;++i) {
|
||||
fig=sp->fig;
|
||||
sp = sprites;
|
||||
for (i = 0; i < spritesused; ++i) {
|
||||
fig = sp->fig;
|
||||
|
||||
solidcopy(&background,
|
||||
sp->xpos+fig->xdelta,sp->ypos+fig->ydelta,
|
||||
fig->xsize,fig->ysize);
|
||||
solidcopy(&background, sp->xpos + fig->xdelta, sp->ypos + fig->ydelta, fig->xsize, fig->ysize);
|
||||
++sp;
|
||||
}
|
||||
}
|
||||
|
||||
void clearsprites(void) {
|
||||
int i;
|
||||
sprite *sp;
|
||||
figure *fig;
|
||||
sprite* sp;
|
||||
figure* fig;
|
||||
|
||||
sp=sprites;
|
||||
for(i=0;i<spritesused;++i) {
|
||||
fig=sp->fig;
|
||||
sp = sprites;
|
||||
for (i = 0; i < spritesused; ++i) {
|
||||
fig = sp->fig;
|
||||
|
||||
clearrect(sp->xpos+fig->xdelta,sp->ypos+fig->ydelta,
|
||||
fig->xsize,fig->ysize);
|
||||
clearrect(sp->xpos + fig->xdelta, sp->ypos + fig->ydelta, fig->xsize, fig->ysize);
|
||||
++sp;
|
||||
}
|
||||
}
|
||||
|
||||
void clearspritelist(void) {
|
||||
spritesused=0;
|
||||
spritesused = 0;
|
||||
}
|
||||
|
||||
int tovideox(int x) {
|
||||
return (x>>FRACTION)+arraystartx;
|
||||
return (x >> FRACTION) + arraystartx;
|
||||
}
|
||||
|
||||
int tovideoy(int y) {
|
||||
return (y>>FRACTION)+arraystarty;
|
||||
return (y >> FRACTION) + arraystarty;
|
||||
}
|
||||
|
||||
int screentoarrayx(int x) {
|
||||
x+=arrayspacex << (FRACTION+2);
|
||||
return ((x>>FRACTION)+(arrayspacex>>1))/arrayspacex-4;
|
||||
x += arrayspacex << (FRACTION + 2);
|
||||
return ((x >> FRACTION) + (arrayspacex >> 1)) / arrayspacex - 4;
|
||||
}
|
||||
|
||||
int screentoarrayy(int y) {
|
||||
y+=arrayspacey << (FRACTION+2);
|
||||
return ((y>>FRACTION)+(arrayspacey>>1))/arrayspacey-4;
|
||||
y += arrayspacey << (FRACTION + 2);
|
||||
return ((y >> FRACTION) + (arrayspacey >> 1)) / arrayspacey - 4;
|
||||
}
|
||||
|
||||
int arraytoscreenx(int x) {
|
||||
return arrayspacex*x<<FRACTION;
|
||||
return arrayspacex * x << FRACTION;
|
||||
}
|
||||
|
||||
int arraytoscreeny(int y) {
|
||||
return arrayspacey*y<<FRACTION;
|
||||
return arrayspacey * y << FRACTION;
|
||||
}
|
||||
|
||||
static void loadfonts(void) {
|
||||
int i,j;
|
||||
const unsigned char *p;
|
||||
int i, j;
|
||||
const unsigned char* p;
|
||||
|
||||
getsingle(fontname,font,NUMCHARACTERS);
|
||||
getsingle(bigfontname,bigfont,NUMCHARACTERS);
|
||||
fontxsize=8;
|
||||
fontysize=12;
|
||||
bigfontxsize=16;
|
||||
bigfontysize=24;
|
||||
bigfontyspace=32;
|
||||
p=remapstring;
|
||||
j=0;while(*p && *p!=' ') ++p,++j;
|
||||
memset(asciiremap,j,sizeof(asciiremap));
|
||||
p=remapstring;
|
||||
i=0;
|
||||
while(*p && i<NUMCHARACTERS)
|
||||
asciiremap[(int)*p++]=i++;
|
||||
getsingle(fontname, font, NUMCHARACTERS);
|
||||
getsingle(bigfontname, bigfont, NUMCHARACTERS);
|
||||
fontxsize = 8;
|
||||
fontysize = 12;
|
||||
bigfontxsize = 16;
|
||||
bigfontysize = 24;
|
||||
bigfontyspace = 32;
|
||||
p = remapstring;
|
||||
j = 0;
|
||||
while (*p && *p != ' ') ++p, ++j;
|
||||
memset(asciiremap, j, sizeof(asciiremap));
|
||||
p = remapstring;
|
||||
i = 0;
|
||||
while (*p && i < NUMCHARACTERS) asciiremap[(int) *p++] = i++;
|
||||
}
|
||||
|
||||
void loadgfx() {
|
||||
gfxset *gs;
|
||||
gfxset *colorgs;
|
||||
gfxset* gs;
|
||||
gfxset* colorgs;
|
||||
int err;
|
||||
int i;
|
||||
char name[267];
|
||||
|
||||
strcpy(walkingname,"walk");
|
||||
strcpy(colorsetname,"pal");
|
||||
strcpy(backgroundname,"field0");
|
||||
strcpy(blocksname,"blocks3");
|
||||
strcpy(blocksxname,"blocks3x");
|
||||
strcpy(bombs1name,"bomb1");
|
||||
strcpy(bombs2name,"bomb2");
|
||||
strcpy(flamesname,"flames");
|
||||
strcpy(tilesname,"tiles");
|
||||
strcpy(deathname,"death1");
|
||||
strcpy(fontname,"font");
|
||||
strcpy(bigfontname,"bigfont");
|
||||
strcpy(walkingname, "walk");
|
||||
strcpy(colorsetname, "pal");
|
||||
strcpy(backgroundname, "field0");
|
||||
strcpy(blocksname, "blocks3");
|
||||
strcpy(blocksxname, "blocks3x");
|
||||
strcpy(bombs1name, "bomb1");
|
||||
strcpy(bombs2name, "bomb2");
|
||||
strcpy(flamesname, "flames");
|
||||
strcpy(tilesname, "tiles");
|
||||
strcpy(deathname, "death1");
|
||||
strcpy(fontname, "font");
|
||||
strcpy(bigfontname, "bigfont");
|
||||
|
||||
gs=malloc((MAXSETS+1)*sizeof(gfxset));
|
||||
if(!gs)
|
||||
nomem("loadgfx");
|
||||
colorgs=gs+1;
|
||||
gs = malloc((MAXSETS + 1) * sizeof(gfxset));
|
||||
if (!gs) nomem("loadgfx");
|
||||
colorgs = gs + 1;
|
||||
|
||||
for(i=0;i<MAXSETS;++i) {
|
||||
snprintf(name,sizeof(name),"%s%d",colorsetname,i);
|
||||
err=dopcx(name,colorgs+i);
|
||||
if(err) continue;
|
||||
for (i = 0; i < MAXSETS; ++i) {
|
||||
snprintf(name, sizeof(name), "%s%d", colorsetname, i);
|
||||
err = dopcx(name, colorgs + i);
|
||||
if (err) continue;
|
||||
}
|
||||
|
||||
loadfonts();
|
||||
texthome();
|
||||
bigscrprintf("Loading graphics...\n");
|
||||
|
||||
err=dopcx(backgroundname,gs);
|
||||
if(err) exit(1000+err);
|
||||
err = dopcx(backgroundname, gs);
|
||||
if (err) exit(1000 + err);
|
||||
createinout(gs);
|
||||
solidfetch(gs,&background);
|
||||
solidfetch(gs,&backgroundoriginal);
|
||||
solidfetch(gs, &background);
|
||||
solidfetch(gs, &backgroundoriginal);
|
||||
freegfxset(gs);
|
||||
|
||||
bigscrprintf("Loading blocks\n");
|
||||
getsingle(blocksname,blocks,3);
|
||||
getsingle(blocksname, blocks, 3);
|
||||
bigscrprintf("Loading block explosions\n");
|
||||
getsingle(blocksxname,blocksx,9);
|
||||
getsingle(blocksxname, blocksx, 9);
|
||||
bigscrprintf("Loading walking figures\n");
|
||||
getgroup(walkingname,colorgs,walking[0],NUMWALKFRAMES);
|
||||
getgroup(walkingname, colorgs, walking[0], NUMWALKFRAMES);
|
||||
bigscrprintf("Loading normal bombs\n");
|
||||
getgroup(bombs1name,colorgs,bombs1[0],NUMBOMBFRAMES);
|
||||
getgroup(bombs1name, colorgs, bombs1[0], NUMBOMBFRAMES);
|
||||
bigscrprintf("Loading controlled bombs\n");
|
||||
getgroup(bombs2name,colorgs,bombs2[0],NUMBOMBFRAMES);
|
||||
getgroup(bombs2name, colorgs, bombs2[0], NUMBOMBFRAMES);
|
||||
bigscrprintf("Loading flames\n");
|
||||
// getgroup(flamesname,colorgs,flamefigs[0],NUMFLAMEFRAMES);
|
||||
getsingle(flamesname,flamefigs[0],NUMFLAMEFRAMES);
|
||||
// getgroup(flamesname,colorgs,flamefigs[0],NUMFLAMEFRAMES);
|
||||
getsingle(flamesname, flamefigs[0], NUMFLAMEFRAMES);
|
||||
bigscrprintf("Loading bonus tiles\n");
|
||||
getsingle(tilesname,tiles,15);
|
||||
getsingle(tilesname, tiles, 15);
|
||||
bigscrprintf("Loading death sequence\n");
|
||||
getsingle(deathname,death,NUMDEATHFRAMES);
|
||||
getsingle(deathname, death, NUMDEATHFRAMES);
|
||||
|
||||
for(i=0;i<MAXSETS;++i)
|
||||
freegfxset(colorgs+i);
|
||||
for (i = 0; i < MAXSETS; ++i) freegfxset(colorgs + i);
|
||||
free(gs);
|
||||
bigscrprintf("Done loading graphics\n");
|
||||
}
|
||||
|
||||
void failure(char *str,...) {
|
||||
void failure(char* str, ...) {
|
||||
char output[256];
|
||||
va_list ap;
|
||||
int len;
|
||||
@ -458,11 +468,11 @@ void failure(char *str,...) {
|
||||
len = vsnprintf(output, sizeof(output), str, ap);
|
||||
if (len >= 256) len = 255; /* truncated string */
|
||||
clear();
|
||||
drawbigstring((IXSIZE - len*bigfontxsize) / 2, (IYSIZE-bigfontysize) / 2, output);
|
||||
drawbigstring((IXSIZE - len * bigfontxsize) / 2, (IYSIZE - bigfontysize) / 2, output);
|
||||
copyup();
|
||||
|
||||
now = longtime();
|
||||
while (!exitflag && longtime()-now < 3) {
|
||||
while (!exitflag && longtime() - now < 3) {
|
||||
scaninput();
|
||||
if (anydown()) {
|
||||
takedown();
|
||||
|
17
src/draw.h
17
src/draw.h
@ -3,12 +3,12 @@
|
||||
|
||||
void loadgfx(void);
|
||||
|
||||
void drawstring(int xpos, int ypos, const char *str);
|
||||
void drawbigstring(int xpos, int ypos, const char *str);
|
||||
void drawstring(int xpos, int ypos, const char* str);
|
||||
void drawbigstring(int xpos, int ypos, const char* str);
|
||||
|
||||
void centerbig(int y, const char *str);
|
||||
void centerbig(int y, const char* str);
|
||||
|
||||
void addsprite(int x,int y,figure *fig);
|
||||
void addsprite(int x, int y, figure* fig);
|
||||
void plotsprites(void);
|
||||
void erasesprites(void);
|
||||
void clearsprites(void);
|
||||
@ -22,10 +22,10 @@ int screentoarrayy(int y);
|
||||
int arraytoscreenx(int x);
|
||||
int arraytoscreeny(int y);
|
||||
|
||||
void failure(char *str,...);
|
||||
void failure(char* str, ...);
|
||||
|
||||
extern int fontxsize,fontysize;
|
||||
extern int bigfontxsize,bigfontysize,bigfontyspace;
|
||||
extern int fontxsize, fontysize;
|
||||
extern int bigfontxsize, bigfontysize, bigfontyspace;
|
||||
|
||||
/* On screen array variables */
|
||||
extern int arraynumx, arraynumy, arraystartx, arraystarty, arrayspacex, arrayspacey;
|
||||
@ -37,6 +37,7 @@ extern int arraynumx, arraynumy, arraystartx, arraystarty, arrayspacex, arrayspa
|
||||
#define NUMDEATHFRAMES 41
|
||||
|
||||
|
||||
extern figure blocks[3], blocksx[9], bombs1[MAXSETS][NUMBOMBFRAMES], bombs2[MAXSETS][NUMBOMBFRAMES], flamefigs[MAXSETS][NUMFLAMEFRAMES], tiles[15], death[NUMDEATHFRAMES];
|
||||
extern figure blocks[3], blocksx[9], bombs1[MAXSETS][NUMBOMBFRAMES], bombs2[MAXSETS][NUMBOMBFRAMES], flamefigs[MAXSETS][NUMFLAMEFRAMES], tiles[15],
|
||||
death[NUMDEATHFRAMES];
|
||||
|
||||
#endif
|
||||
|
813
src/game.c
813
src/game.c
File diff suppressed because it is too large
Load Diff
14
src/game.h
14
src/game.h
@ -1,11 +1,13 @@
|
||||
#ifndef GAME_H
|
||||
#define GAME_H
|
||||
|
||||
#include "bomber.h"
|
||||
|
||||
#define FRACTION 9
|
||||
#define SPEEDDELTA (1<<(FRACTION-1))
|
||||
#define SPEEDMAX (10<<FRACTION)
|
||||
#define SPEEDSTART (6<<FRACTION)
|
||||
#define SPEEDTURTLE (3<<FRACTION)
|
||||
#define SPEEDDELTA (1 << (FRACTION - 1))
|
||||
#define SPEEDMAX (10 << FRACTION)
|
||||
#define SPEEDSTART (6 << FRACTION)
|
||||
#define SPEEDTURTLE (3 << FRACTION)
|
||||
#define SPEEDTURTLE_TIMEOUT 250
|
||||
|
||||
#define TEMPNODES 2
|
||||
@ -18,10 +20,10 @@ struct GameOptions {
|
||||
void run_single_player(void);
|
||||
void run_network_game(void);
|
||||
|
||||
void set_game_options(GameOptions *options);
|
||||
void set_game_options(GameOptions* options);
|
||||
|
||||
extern char playername[16];
|
||||
|
||||
extern solid background,backgroundoriginal;
|
||||
extern solid background, backgroundoriginal;
|
||||
|
||||
#endif
|
56
src/gfx.h
56
src/gfx.h
@ -8,15 +8,15 @@
|
||||
extern int usedcolors;
|
||||
extern uchar mymap[];
|
||||
extern int screen;
|
||||
extern int fontbase,fontysize;
|
||||
extern char *imageloc;
|
||||
extern int fontbase, fontysize;
|
||||
extern char* imageloc;
|
||||
|
||||
extern long map2[];
|
||||
extern uchar fmap[128];
|
||||
extern int buttonstate,buttondown;
|
||||
extern int mxpos,mypos;
|
||||
extern int buttonstate, buttondown;
|
||||
extern int mxpos, mypos;
|
||||
|
||||
extern int pressedcodes[KEYMAX],downcodes[KEYMAX],numpressed,numdown;
|
||||
extern int pressedcodes[KEYMAX], downcodes[KEYMAX], numpressed, numdown;
|
||||
|
||||
|
||||
void opengfx(void);
|
||||
@ -25,21 +25,21 @@ void gfxunlock(void);
|
||||
void pollinput(void);
|
||||
int takedown(void);
|
||||
void closegfx(void);
|
||||
void greyrect(int x,int y,int xsize,int ysize);
|
||||
void clearrect(int x,int y,int xsize,int ysize);
|
||||
void solidfetch(gfxset *gs,solid *dest);
|
||||
void greyrect(int x, int y, int xsize, int ysize);
|
||||
void clearrect(int x, int y, int xsize, int ysize);
|
||||
void solidfetch(gfxset* gs, solid* dest);
|
||||
extern void dumpgfx(void);
|
||||
extern void createinout(struct gfxset *);
|
||||
extern void createinout(struct gfxset*);
|
||||
extern void getcolors(void);
|
||||
extern void gfxfetch(struct gfxset *,struct figure *,int);
|
||||