Code clean up.

This commit is contained in:
Steve 2018-03-30 19:23:57 +01:00
parent e59b0f9461
commit 302997cb31
10 changed files with 5 additions and 131 deletions

View File

@ -53,10 +53,6 @@ Boss *initBoss(void)
return b;
}
void bossIdle(void)
{
}
static void init(void)
{
}

View File

@ -32,36 +32,3 @@ Entity *initHorizontalDoor(void)
return (Entity*)s;
}
Entity *initBronzeHorizontalDoor(void)
{
Structure *s;
s = (Structure*)initHorizontalDoor();
STRNCPY(s->requiredItem, "Bronze Key", MAX_NAME_LENGTH);
return (Entity*)s;
}
Entity *initSilverHorizontalDoor(void)
{
Structure *s;
s = (Structure*)initHorizontalDoor();
STRNCPY(s->requiredItem, "Silver Key", MAX_NAME_LENGTH);
return (Entity*)s;
}
Entity *initGoldHorizontalDoor(void)
{
Structure *s;
s = (Structure*)initHorizontalDoor();
STRNCPY(s->requiredItem, "Gold Key", MAX_NAME_LENGTH);
return (Entity*)s;
}

View File

@ -26,6 +26,7 @@ extern void blitRectScaled(SDL_Texture *texture, int x, int y, int w, int h, SDL
extern void drawRect(int x, int y, int w, int h, int r, int g, int b, int a);
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
extern void endSectionTransition(void);
extern void fadeMusic(int ms);
extern Atlas *getImageFromAtlas(char *filename);
extern Texture *getTexture(const char *filename);
extern int getWrappedTextHeight(const char *text, int size);
@ -33,7 +34,6 @@ extern void initCredits(int playMusic);
extern void limitTextWidth(int width);
extern char *readFile(const char *filename);
extern void startSectionTransition(void);
extern void fadeMusic(int ms);
extern App app;
extern Colors colors;

View File

@ -131,6 +131,7 @@ void initGameSystem(void)
int i, numInitFuns;
void (*initFuncs[]) (void) = {
initGraphics,
initTextures,
initBackground,
initFonts,
initAtlas,

View File

@ -44,6 +44,7 @@ extern void initGraphics(void);
extern void initSounds(void);
extern void initSprites(void);
extern void initStats(void);
extern void initTextures(void);
extern void initTrophies(void);
extern void initWidgets(void);
extern long lookup(const char *name);

View File

@ -166,31 +166,6 @@ const char *getFlagValues(const char *prefix, long flags)
return flagStr;
}
long flagsToLong(const char *in)
{
char *flag, *flags;
long total;
total = 0;
if (strlen(in) > 0)
{
flags = malloc(strlen(in) + 1);
STRNCPY(flags, in, strlen(in) + 1);
flag = strtok(flags, "+");
while (flag)
{
total += lookup(flag);
flag = strtok(NULL, "+");
}
free(flags);
}
return total;
}
void destroyLookups(void)
{
Lookup *l;

View File

@ -19,5 +19,3 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../common.h"
long flagsToLong(const char *in);

View File

@ -61,21 +61,6 @@ void fadeMusic(int ms)
Mix_FadeOutMusic(ms);
}
void musicSetPlaying(int playing)
{
if (music != NULL)
{
if (playing)
{
Mix_ResumeMusic();
}
else
{
Mix_PauseMusic();
}
}
}
void playSound(int snd, int ch)
{
Mix_PlayChannel(ch, sounds[snd], 0);

View File

@ -27,40 +27,6 @@ int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
return (MAX(x1, x2) < MIN(x1 + w1, x2 + w2)) && (MAX(y1, y2) < MIN(y1 + h1, y2 + h2));
}
int lineLineIntersection(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
int d, n1, n2, ua, ub;
d = ((y4 - y3) * (x2 - x1)) - ((x4 - x3) * (y2 - y1));
n1 = ((x4 - x3) * (y1 - y3)) - ((y4 - y3) * (x1 - x3));
n2 = ((x2 - x1) * (y1 - y3)) - ((y2 - y1) * (x1 - x3));
if (d == 0)
{
if ( n1 == 0 && n2 == 0)
{
return 0;
}
return 0;
}
ua = n1 / d;
ub = n2 / d;
return (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1);
}
int lineRectIntersection(int x1, int y1, int x2, int y2, SDL_Rect *r)
{
return (
lineLineIntersection(x1, y1, x2, y2, r->x, r->y, r->x + r->w, r->y) || /* top */
lineLineIntersection(x1, y1, x2, y2, r->x, r->y + r->h, r->x + r->w, r->y + r->h) || /* bottom */
lineLineIntersection(x1, y1, x2, y2, r->x, r->y, r->x, r->y + r->h) || /* left */
lineLineIntersection(x1, y1, x2, y2, r->x + r->w, r->y, r->x + r->w, r->y + r->h) /* right */
);
}
char *timeToString(int seconds, int showHours)
{
int hours, minutes;

View File

@ -570,14 +570,14 @@ static int canWalkOnEntity(float x, float y)
srcRect.x = x;
srcRect.y = y;
srcRect.w = 8;
srcRect.w = self->w;
srcRect.h = MAP_TILE_SIZE * 4;
candidates = getAllEntsWithin(srcRect.x, srcRect.y, srcRect.w, srcRect.h, NULL);
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
{
if (self != e && e->isSolid && collision(x, y, 1, MAP_TILE_SIZE * 2, e->x, e->y, e->w, e->y))
if (self != e && e->isSolid && collision(x, y, self->w, 8, e->x, e->y, e->w, e->y))
{
return 1;
}
@ -1047,21 +1047,6 @@ void teleport(Entity *e, float tx, float ty)
}
}
Entity *findEntity(char *name)
{
Entity *e;
for (e = world.entityHead.next ; e != NULL ; e = e->next)
{
if (strcmp(e->name, name) == 0)
{
return e;
}
}
return NULL;
}
Entity *getRandomObjectiveEntity(void)
{
Entity *rtn, *e;