Skip to content

Commit

Permalink
Code clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenjsweeney committed Mar 30, 2018
1 parent e59b0f9 commit 302997c
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 131 deletions.
4 changes: 0 additions & 4 deletions src/entities/boss/boss.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ Boss *initBoss(void)
return b;
}

void bossIdle(void)
{
}

static void init(void)
{
}
Expand Down
33 changes: 0 additions & 33 deletions src/entities/structures/horizontalDoor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/game/ending.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ 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);
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;
1 change: 1 addition & 0 deletions src/system/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ void initGameSystem(void)
int i, numInitFuns;
void (*initFuncs[]) (void) = {
initGraphics,
initTextures,
initBackground,
initFonts,
initAtlas,
Expand Down
1 change: 1 addition & 0 deletions src/system/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 0 additions & 25 deletions src/system/lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/system/lookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "../common.h"

long flagsToLong(const char *in);
15 changes: 0 additions & 15 deletions src/system/sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
34 changes: 0 additions & 34 deletions src/util/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 2 additions & 17 deletions src/world/entities.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 302997c

Please sign in to comment.