diff --git a/common.mk b/common.mk index 3fb87d1..4552504 100644 --- a/common.mk +++ b/common.mk @@ -4,9 +4,9 @@ LOCALE_MO = $(patsubst %.po,%.mo,$(wildcard locale/*.po)) OUT = bin -SEARCHPATH += src -SEARCHPATH += src/combat -SEARCHPATH += src/entities +SEARCHPATH += src +SEARCHPATH += src/combat +SEARCHPATH += src/entities SEARCHPATH += src/entities/blobs SEARCHPATH += src/entities/boss SEARCHPATH += src/entities/bullets @@ -23,8 +23,8 @@ SEARCHPATH += src/hub SEARCHPATH += src/json SEARCHPATH += src/system SEARCHPATH += src/test -SEARCHPATH += src/util -SEARCHPATH += src/widgets +SEARCHPATH += src/util +SEARCHPATH += src/widgets SEARCHPATH += src/world vpath %.c $(SEARCHPATH) @@ -63,10 +63,10 @@ all: $(PROG) $(LOCALE_MO) $(OUT)/%.o: %.c %.h $(DEPS) @mkdir -p $(OUT) $(CC) $(CFLAGS) $(CXXFLAGS) -c -o $@ $< - + %.mo: %.po msgfmt -c -o $@ $< - + # cleaning everything that can be automatically recreated with "make". clean: $(RM) $(OBJS) $(PROG) $(LOCALE_MO) diff --git a/gfx/atlas/atlas.png b/gfx/atlas/atlas.png index bf91126..0b0e5c3 100644 Binary files a/gfx/atlas/atlas.png and b/gfx/atlas/atlas.png differ diff --git a/makefile b/makefile index dbf19e4..62226e0 100644 --- a/makefile +++ b/makefile @@ -19,6 +19,9 @@ _OBJS += unixInit.o include common.mk +NPROCS = $(shell grep -c 'processor' /proc/cpuinfo) +MAKEFLAGS += -j$(NPROCS) + CXXFLAGS += `sdl2-config --cflags` -DVERSION=$(VERSION) -DREVISION=$(REVISION) -DDATA_DIR=\"$(DATA_DIR)\" -DLOCALE_DIR=\"$(LOCALE_DIR)\" CXXFLAGS += -g -lefence CXXFLAGS += -fms-extensions -std=gnu11 @@ -55,13 +58,13 @@ install: cp -p icons/$(PROG)-128x128.png $(INST_ICON_DIR)/128x128/apps/$(PROG).png mkdir -p $(INST_DESKTOP_DIR) cp -p icons/$(PROG).desktop $(INST_DESKTOP_DIR) - + @for f in $(LOCALE_MO); do \ lang=`echo $$f | sed -e 's/^locale\///;s/\.mo$$//'`; \ mkdir -p $(INST_LOCALE_DIR)/$$lang/LC_MESSAGES; \ cp -v $$f $(INST_LOCALE_DIR)/$$lang/LC_MESSAGES/$(PROG).mo; \ done - + uninstall: $(RM) $(BIN_DIR)/$(PROG) $(RM) -rf $(DATA_DIR) @@ -70,7 +73,7 @@ uninstall: $(RM) $(ICON_DIR)/64x64/apps/$(PROG).png $(RM) $(ICON_DIR)/128x128/apps/$(PROG).png $(RM) $(DESKTOP_DIR)/$(PROG).desktop - + @for f in $(LOCALE_MO); do \ lang=`echo $$f | sed -e 's/^locale\///;s/\.mo$$//'`; \ $(RM) -v $(LOCALE_DIR)/$$lang/LC_MESSAGES/$(PROG).mo; \ @@ -85,7 +88,7 @@ dist: mkdir -p dist mv $(PROG)-$(VERSION).$(REVISION).linux-x86.tar.gz dist $(RM) -rf $(PROG)-$(VERSION).$(REVISION) - + # prepare an archive for the program src-dist: $(RM) -rf $(PROG)-$(VERSION).$(REVISION) diff --git a/src/combat/combat.c b/src/combat/combat.c index 48e14c7..f4bc93a 100644 --- a/src/combat/combat.c +++ b/src/combat/combat.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -26,37 +26,37 @@ int hasLineOfSight(Entity *src, Entity *dest) float sx, sy, tx, ty, dx, dy; Entity **candidates, *e; SDL_Rect losBounds; - + sx = src->x + (src->w / 2); sy = src->y + (src->h / 2); tx = dest->x + (dest->w / 2); ty = dest->y + (dest->h / 2); - + losBounds.x = (int) MIN(src->x, dest->x); losBounds.y = (int) MIN(src->y, dest->y); losBounds.w = (int) (MAX(src->x, dest->x) - losBounds.x); losBounds.h = (int) (MAX(src->y, dest->y) - losBounds.y); - + candidates = getAllEntsWithin(losBounds.x, losBounds.y, losBounds.w, losBounds.h, NULL); - + getSlope(sx, sy, tx, ty, &dx, &dy); - + dx *= 8; dy *= 8; - + while (1) { sx -= dx; sy -= dy; - + mx = sx / MAP_TILE_SIZE; my = sy / MAP_TILE_SIZE; - + if (isSolid(mx, my)) { return 0; } - + for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i]) { if (e != src && collision(sx, sy, 8, 8, e->x, e->y, e->w, e->h)) @@ -65,7 +65,7 @@ int hasLineOfSight(Entity *src, Entity *dest) { return 0; } - + if (e == dest) { return 1; @@ -73,7 +73,7 @@ int hasLineOfSight(Entity *src, Entity *dest) } } } - + return 0; } diff --git a/src/combat/combat.h b/src/combat/combat.h index 4fa8e2e..8fd01d8 100644 --- a/src/combat/combat.h +++ b/src/combat/combat.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/combat/explosions.c b/src/combat/explosions.c index 24b4105..c1d4bf5 100644 --- a/src/combat/explosions.c +++ b/src/combat/explosions.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -29,7 +29,7 @@ void addExplosion(float x, float y, int radius, Entity *owner) Entity **candidates, *e; float power; int i; - + playBattleSound(SND_EXPLOSION, 0, x, y); /* assuming x and y were from the top left of the entity */ @@ -42,7 +42,7 @@ void addExplosion(float x, float y, int radius, Entity *owner) radiusRect.y = (int) (y - radius); radiusRect.w = radius * 2; radiusRect.h = radius * 2; - + if (killTimer < SDL_GetTicks()) { numKilled = 0; @@ -77,17 +77,17 @@ void addExplosion(float x, float y, int radius, Entity *owner) { stunBob(); } - + if (owner->type == ET_ENEMY && e->health <= 0 && e->type == ET_ENEMY && strstr(((Unit*)owner)->unitType, "EyeDroid")) { game.stats[STAT_EYE_DROID_EXPLOSION_KILLS]++; } - + if (e->health <= 0) { e->dx = rrnd(-radius / 8, radius / 8); e->dy = rrnd(-5, 0); - + if (owner->type == ET_BOB) { numKilled++; @@ -104,7 +104,7 @@ void addExplosion(float x, float y, int radius, Entity *owner) setGameplayMessage(MSG_STANDARD, "%d hit grenade combo!", numKilled); game.stats[STAT_GRENADE_COMBO] = MAX(game.stats[STAT_GRENADE_COMBO], numKilled); - + if (numKilled >= 12) { awardTrophy("GRENADE_COMBO"); diff --git a/src/combat/explosions.h b/src/combat/explosions.h index 0d8e9d4..9b1c53f 100644 --- a/src/combat/explosions.h +++ b/src/combat/explosions.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/combat/weapons.c b/src/combat/weapons.c index 2968cea..6517ffa 100644 --- a/src/combat/weapons.c +++ b/src/combat/weapons.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -56,7 +56,7 @@ void initWeapons(void) missileSprite[0] = getSprite("MissileRight"); missileSprite[1] = getSprite("MissileLeft"); - + weaponName[WPN_PISTOL] = _("Pistol"); weaponName[WPN_PLASMA] = _("Plasma Rifle"); weaponName[WPN_SPREAD] = _("Spread Gun"); @@ -68,7 +68,7 @@ void initWeapons(void) void firePistol(void) { Bullet *bullet; - + if (world.bob->facing != FACING_DIE) { bullet = createBaseBullet((Unit*)world.bob, bulletSprite[0]->frames[0]->rect.w); @@ -88,7 +88,7 @@ void fireAimedShot(Unit *owner) int x, y; float dx, dy; Bullet *bullet; - + if (owner->facing != FACING_DIE) { x = (int) (world.bob->x + rrnd(-8, 24)); @@ -112,7 +112,7 @@ void fireAimedShot(Unit *owner) void fireMachineGun(Unit *owner) { Bullet *bullet; - + if (owner->facing != FACING_DIE) { bullet = createBaseBullet(owner, bulletSprite[0]->w); @@ -128,7 +128,7 @@ void fireMachineGun(Unit *owner) void firePlasma(Unit *owner) { Bullet *bullet; - + if (owner->facing != FACING_DIE) { bullet = createBaseBullet(owner, plasmaSprite[0]->w); @@ -173,7 +173,7 @@ void fireSpread(Unit *owner, int numberOfShots) void fireLaser(Unit *owner) { Bullet *laser; - + if (owner->facing != FACING_DIE) { laser = createBaseBullet(owner, laserSprite[0]->w); @@ -193,7 +193,7 @@ void fireLaser(Unit *owner) void fireGrenade(Unit *owner) { Bullet *grenade; - + if (owner->facing != FACING_DIE) { grenade = createBaseBullet(owner, grenadeSprite->w); @@ -217,7 +217,7 @@ void fireShotgun(Unit *owner) int i; float dx, dy; Bullet *bullet; - + if (owner->facing != FACING_DIE) { for (i = 0 ; i < 8 ; i++) @@ -243,7 +243,7 @@ void fireShotgun(Unit *owner) void fireMissile(Unit *owner) { Bullet *missile; - + if (owner->facing != FACING_DIE) { missile = createBaseBullet(owner, missileSprite[0]->w); diff --git a/src/combat/weapons.h b/src/combat/weapons.h index 92fe3a6..ed5b21f 100644 --- a/src/combat/weapons.h +++ b/src/combat/weapons.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/common.h b/src/common.h index e76bb5d..93deea8 100644 --- a/src/common.h +++ b/src/common.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/defs.h b/src/defs.h index b8f71ad..f5c4e33 100644 --- a/src/defs.h +++ b/src/defs.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/blobs/bob.c b/src/entities/blobs/bob.c index 18199b7..a4bc786 100644 --- a/src/entities/blobs/bob.c +++ b/src/entities/blobs/bob.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -54,12 +54,12 @@ static int oldFacing; Entity *initBob(void) { Bob *b; - + b = malloc(sizeof(Bob)); memset(b, 0, sizeof(Bob)); - + initEntity((Entity*)b); - + STRNCPY(b->name, "Bob", MAX_NAME_LENGTH); b->type = ET_BOB; @@ -83,9 +83,9 @@ Entity *initBob(void) b->reload = 0; b->flags |= EF_SWIMS | EF_BOMB_SHIELD; - + superAnimate = b->animate; - + b->tick = tick; b->init = init; b->applyDamage = applyDamage; @@ -96,21 +96,21 @@ Entity *initBob(void) b->die = die; b->load = load; b->save = save; - + checkpointTimer = 0; - + oldFacing = b->facing; - + return (Entity*)b; } static void init(void) { changeSprite(walkSprite); - + world.bob->checkpoints[0].x = world.bob->x; world.bob->checkpoints[0].y = world.bob->y; - + superAnimate(); } @@ -243,7 +243,7 @@ static void handeImmunity(void) world.bob->checkpoints[i].x = world.bob->checkpoints[i - 1].x; world.bob->checkpoints[i].y = world.bob->checkpoints[i - 1].y; } - + world.bob->checkpoints[0].x = world.bob->x; world.bob->checkpoints[0].y = world.bob->y; checkpointTimer = FPS; @@ -361,11 +361,11 @@ static void doBobInWater(void) static void doDying(void) { int mx, my; - + if (--world.bob->health <= -(FPS * 2)) { world.bob->flags |= EF_GONE; - + if (app.config.blood) { throwFleshChunks(world.bob->x + world.bob->w / 2, world.bob->y + world.bob->h / 2, rrnd(3, 6)); @@ -385,7 +385,7 @@ static void doDying(void) { playSound(SND_POP, world.bob->uniqueId % MAX_SND_CHANNELS); } - + mx = (int) ((world.bob->x + (world.bob->w / 2)) / MAP_TILE_SIZE); my = (int) (world.bob->y / MAP_TILE_SIZE) + 1; addBloodDecal(mx, my); @@ -472,7 +472,7 @@ static void bobWalk(void) { fireWeapon(); } - + if (isControl(CONTROL_JETPACK)) { activate(1); @@ -511,7 +511,7 @@ static void bobSwim(void) { firePistol(); } - + if (isControl(CONTROL_JETPACK)) { activate(1); @@ -549,7 +549,7 @@ static void bobFly(void) { fireWeapon(); } - + if (isControl(CONTROL_JETPACK)) { activate(1); @@ -618,7 +618,7 @@ void resetAtCheckpoint(void) { world.bob->x = world.bob->checkpoints[0].x; world.bob->y = world.bob->checkpoints[0].y; - + world.bob->facing = oldFacing; world.bob->outTimer = 0; world.bob->flags |= EF_FLICKER; @@ -666,7 +666,7 @@ static void die(void) static SDL_Rect *getCurrentSprite(void) { Sprite *s; - + s = (world.bob->alive == ALIVE_ALIVE && world.bob->stunTimer <= 0) ? world.bob->sprite[world.bob->facing] : world.bob->sprite[FACING_DIE]; { return &world.bob->sprite[world.bob->facing]->frames[world.bob->spriteFrame]->rect; @@ -677,7 +677,7 @@ static SDL_Rect *getCurrentSprite(void) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "WARNING: %s (%d) bad sprite frames - %d > %d\n", world.bob->name, world.bob->type, world.bob->spriteFrame, s->numFrames); world.bob->spriteFrame = 0; } - + return &s->frames[world.bob->spriteFrame]->rect; } @@ -689,9 +689,9 @@ static void animate(void) { oldFacing = world.bob->facing; } - + world.bob->facing = FACING_DIE; - + superAnimate(); } else if (world.bob->dx != 0 || world.bob->flags & EF_WEIGHTLESS) @@ -705,7 +705,7 @@ static void load(cJSON *root) world.bob->x = cJSON_GetObjectItem(root, "x")->valueint; world.bob->y = cJSON_GetObjectItem(root, "y")->valueint; world.bob->facing = lookup(cJSON_GetObjectItem(root, "facing")->valuestring); - + if (game.plus & PLUS_MIRROR) { world.bob->x = MAP_PIXEL_WIDTH - world.bob->x; @@ -719,7 +719,7 @@ static void save(cJSON *root) { world.bob->facing = oldFacing; } - + cJSON_AddStringToObject(root, "type", "Bob"); cJSON_AddNumberToObject(root, "x", world.bob->checkpoints[0].x); cJSON_AddNumberToObject(root, "y", world.bob->checkpoints[0].y); diff --git a/src/entities/blobs/bob.h b/src/entities/blobs/bob.h index dec15ce..15e181f 100644 --- a/src/entities/blobs/bob.h +++ b/src/entities/blobs/bob.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/blobs/mia.c b/src/entities/blobs/mia.c index 4c75dae..01ab9d7 100644 --- a/src/entities/blobs/mia.c +++ b/src/entities/blobs/mia.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -32,14 +32,14 @@ static void save(cJSON *root); Entity *initMIA(void) { MIA *m; - + m = malloc(sizeof(MIA)); memset(m, 0, sizeof(MIA)); - + initEntity((Entity*)m); - + m->type = ET_MIA; - + m->tx = m->ty = -1; m->sprite[FACING_LEFT] = getSprite("MIA"); @@ -60,7 +60,7 @@ Entity *initMIA(void) m->save = save; m->isMissionTarget = 1; - + return (Entity*)m; } @@ -81,9 +81,9 @@ static void reset(void) static void tick(void) { MIA *m; - + m = (MIA*)self; - + if (--m->shudderTimer <= 0) { m->x = (m->tx + rand() % 4); @@ -97,7 +97,7 @@ static void tick(void) addMIATeleportStars(m->x + rand() % m->w, m->y + rand() % m->h); m->starTimer = 1; } - + world.saveDelay = FPS; } } @@ -105,9 +105,9 @@ static void tick(void) static void touch(Entity *other) { MIA *m; - + m = (MIA*)self; - + if (m->isMissionTarget && other == (Entity*)world.bob) { m->action = preTeleport; @@ -125,49 +125,49 @@ static void touch(Entity *other) static void preTeleport(void) { MIA *m; - + m = (MIA*)self; - + if (--m->teleportTimer <= FPS) { m->action = teleport; m->flags |= (EF_NO_CLIP | EF_WEIGHTLESS); m->dy = -5; } - + world.saveDelay = FPS; } static void teleport(void) { MIA *m; - + m = (MIA*)self; - + if (--m->teleportTimer <= 0) { addTeleportStars(self); m->alive = ALIVE_DEAD; } - + world.saveDelay = FPS; } static void load(cJSON *root) { MIA *m; - + m = (MIA*)self; - + m->active = cJSON_GetObjectItem(root, "isMissionTarget")->valueint; } static void save(cJSON *root) { MIA *m; - + m = (MIA*)self; - + cJSON_AddStringToObject(root, "type", "MIA"); cJSON_AddNumberToObject(root, "isMissionTarget", m->isMissionTarget); } diff --git a/src/entities/blobs/mia.h b/src/entities/blobs/mia.h index b1dd67a..e3886fb 100644 --- a/src/entities/blobs/mia.h +++ b/src/entities/blobs/mia.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/blobs/teeka.c b/src/entities/blobs/teeka.c index 92cca4d..7f8928e 100644 --- a/src/entities/blobs/teeka.c +++ b/src/entities/blobs/teeka.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -33,13 +33,13 @@ static int exitMission; Entity *initTeeka(void) { Unit *u; - + u = createUnit(); - + u->unitType = "Teeka"; - + u->type = ET_TEEKA; - + u->flags |= EF_IMMUNE; u->action = lookForEnemies; @@ -51,15 +51,15 @@ Entity *initTeeka(void) u->sprite[FACING_DIE] = getSprite("TeekaLeft"); u->health = u->healthMax = 9999; - + superTick = u->tick; - + u->tick = tick; - + exitMission = 0; - + aimedSprite = getSprite("AimedShot"); - + return (Entity*)u; } @@ -87,13 +87,13 @@ static void lookForEnemies(void) Entity *e; float distance, range; Unit *u; - + u = (Unit*)self; - + u->thinkTime = rrnd(FPS / 2, FPS); target = NULL; - + distance = 800; for (e = world.entityHead.next ; e != NULL ; e = e->next) @@ -134,9 +134,9 @@ static void lookForEnemies(void) static void preFire(void) { Unit *u; - + u = (Unit*)self; - + if (u->reload > 0) { return; @@ -148,7 +148,7 @@ static void preFire(void) } attack(); - + if (--u->shotsToFire <= 0) { u->thinkTime = FPS; @@ -160,7 +160,7 @@ static void attack(void) { Bullet *bullet; float dx, dy; - + getSlope(target->x, target->y, self->x, self->y, &dx, &dy); bullet = createBaseBullet((Unit*)self, aimedSprite->w); diff --git a/src/entities/blobs/teeka.h b/src/entities/blobs/teeka.h index 357ef89..9ee8b09 100644 --- a/src/entities/blobs/teeka.h +++ b/src/entities/blobs/teeka.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/boss/blaze.c b/src/entities/boss/blaze.c index 6e6a4df..6d3f987 100644 --- a/src/entities/boss/blaze.c +++ b/src/entities/boss/blaze.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -23,16 +23,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Entity *initBlaze(void) { Boss *b; - + b = initBlobBoss(); - + b->weakAgainst = ENV_WATER; - + STRNCPY(b->name, "Blaze", MAX_NAME_LENGTH); b->sprite[FACING_LEFT] = getSprite("BlazeLeft"); b->sprite[FACING_RIGHT] = getSprite("BlazeRight"); b->sprite[FACING_DIE] = getSprite("BlazeSpin"); - + return (Entity*)b; } diff --git a/src/entities/boss/blaze.h b/src/entities/boss/blaze.h index 2b9e033..7def318 100644 --- a/src/entities/boss/blaze.h +++ b/src/entities/boss/blaze.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/boss/blobBoss.c b/src/entities/boss/blobBoss.c index be88138..7237262 100644 --- a/src/entities/boss/blobBoss.c +++ b/src/entities/boss/blobBoss.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -40,17 +40,17 @@ static Sprite *aimedSprite; Boss *initBlobBoss(void) { Boss *b; - + b = initBoss(); - + b->flags |= EF_HALT_AT_EDGE; b->health = b->healthMax = 250; b->teleportTimer = FPS * rrnd(4, 6); - + superAnimate = b->animate; - + b->activate = activate; b->action = walk; b->walk = walk; @@ -60,9 +60,9 @@ Boss *initBlobBoss(void) b->animate = animate; b->applyDamage = applyDamage; b->die = die1; - + aimedSprite = getSprite("AimedShot"); - + return b; } @@ -83,9 +83,9 @@ static void activate(int activate) static void tick(void) { Boss *b; - + b = (Boss*)self; - + if (b->health > 0) { b->stunTimer = MAX(b->stunTimer - 1, 0); @@ -95,7 +95,7 @@ static void tick(void) b->health -= 2; world.boss = b; - + if (b->stunTimer == 0) { teleport(); @@ -125,9 +125,9 @@ static void tick(void) static void changeEnvironment() { Boss *b; - + b = (Boss*)self; - + if (b->environment == b->weakAgainst) { b->teleportTimer = 0; @@ -143,9 +143,9 @@ static void changeEnvironment() static void die1(void) { Boss *b; - + b = (Boss*)self; - + b->flags |= EF_BOUNCES; b->thinkTime = 0; @@ -176,7 +176,7 @@ static void die1(void) playBattleSound(SND_DEATH_3, b->uniqueId % MAX_SND_CHANNELS, b->x, b->y); break; } - + b->action = die2; } @@ -184,9 +184,9 @@ static SDL_Rect *getCurrentSprite(void) { Boss *b; Sprite *s; - + b = (Boss*)self; - + s = (b->stunTimer > 0 || b->health <= 0) ? b->sprite[FACING_DIE] : b->sprite[b->facing]; if (self->spriteFrame >= s->numFrames) @@ -194,20 +194,20 @@ static SDL_Rect *getCurrentSprite(void) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "WARNING: %s (%d) bad sprite frames - %d > %d\n", self->name, self->type, self->spriteFrame, s->numFrames); self->spriteFrame = 0; } - + return &s->frames[self->spriteFrame]->rect; } static void animate(void) { Boss *b; - + b = (Boss*)self; - + if (b->alive != ALIVE_ALIVE || b->stunTimer > 0) { b->facing = FACING_DIE; - + superAnimate(); } else if (b->dx != 0) @@ -219,9 +219,9 @@ static void animate(void) static void lookForPlayer(void) { Boss *b; - + b = (Boss*)self; - + b->thinkTime = rrnd(0, FPS / 2); if (getDistance(world.bob->x, world.bob->y, b->x, b->y) > 650) @@ -248,9 +248,9 @@ static void lookForPlayer(void) static void moveTowardsPlayer(void) { Boss *b; - + b = (Boss*)self; - + b->dx = 0; if (rand() % 100 < 20) @@ -282,9 +282,9 @@ static void moveTowardsPlayer(void) static void preFire(void) { Boss *b; - + b = (Boss*)self; - + if (b->reload > 0) { return; @@ -305,7 +305,7 @@ static void attack(void) Bullet *bullet; float dx, dy; int bx, by; - + if (self->facing != FACING_DIE) { bx = (int) (world.bob->x + rrnd(-8, 24)); @@ -337,9 +337,9 @@ static void walk(void) void reappear(void) { int valid, r; - + valid = 0; - + do { r = (int) (rand() % MAX_CHECKPOINTS); @@ -348,15 +348,15 @@ void reappear(void) valid = (self->x != 0 && self->y != 0); } while (!valid); - + self->y -= (self->h + 10); - + walk(); - + self->flags &= ~EF_GONE; - + addTeleportStars(self); - + playBattleSound(SND_APPEAR, -1, self->x, self->y); } @@ -389,9 +389,9 @@ static void teleport(void) static void die2(void) { Boss *b; - + b = (Boss*)self; - + b->health--; if (b->health <= -FPS) @@ -413,7 +413,7 @@ static void die2(void) { awardTrophy("BLAZE_FROST"); } - + b->action = entityIdle; } } diff --git a/src/entities/boss/blobBoss.h b/src/entities/boss/blobBoss.h index fb97f20..9edb510 100644 --- a/src/entities/boss/blobBoss.h +++ b/src/entities/boss/blobBoss.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/boss/boss.c b/src/entities/boss/boss.c index fa60d22..28d4a83 100644 --- a/src/entities/boss/boss.c +++ b/src/entities/boss/boss.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -27,16 +27,16 @@ static void init(void); Boss *initBoss(void) { Boss *b; - + b = malloc(sizeof(Boss)); memset(b, 0, sizeof(Boss)); - + initEntity((Entity*)b); - + b->type = ET_BOSS; - + b->sprite[FACING_LEFT] = b->sprite[FACING_RIGHT] = b->sprite[FACING_DIE] = getSprite("Boss"); - + b->isMissionTarget = 1; b->spriteFrame = 0; @@ -45,11 +45,11 @@ Boss *initBoss(void) world.boss = b; b->flags |= EF_ALWAYS_PROCESS | EF_BOMB_SHIELD | EF_GONE; - + b->init = init; b->load = load; b->save = save; - + return b; } diff --git a/src/entities/boss/boss.h b/src/entities/boss/boss.h index 6acd68f..2c8cb46 100644 --- a/src/entities/boss/boss.h +++ b/src/entities/boss/boss.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/boss/eyeDroidCommander.c b/src/entities/boss/eyeDroidCommander.c index 4a0d5da..5369104 100644 --- a/src/entities/boss/eyeDroidCommander.c +++ b/src/entities/boss/eyeDroidCommander.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -43,19 +43,19 @@ static Sprite *plasmaSprite[2]; Entity *initEyeDroidCommander(void) { Boss *b; - + b = initBoss(); - + STRNCPY(b->name, "EyeDroid Commander", MAX_NAME_LENGTH); b->sprite[FACING_LEFT] = getSprite("DroidCommanderLeft"); b->sprite[FACING_RIGHT] = getSprite("DroidCommanderRight"); b->sprite[FACING_DIE] = getSprite("DroidCommanderDie"); - + b->flags |= EF_WEIGHTLESS | EF_EXPLODES; b->health = b->healthMax = 250; - + b->action = walk; b->walk = walk; b->tick = tick; @@ -65,15 +65,15 @@ Entity *initEyeDroidCommander(void) b->getCurrentSprite = getCurrentSprite; brakingTimer = 0; - + aimedSprite = getSprite("AimedShot"); - + missileSprite[0] = getSprite("MissileRight"); missileSprite[1] = getSprite("MissileLeft"); - + plasmaSprite[0] = getSprite("PlasmaRight"); plasmaSprite[1] = getSprite("PlasmaLeft"); - + return (Entity*)b; } @@ -91,9 +91,9 @@ static void activate(int activate) static void tick(void) { Boss *b; - + b = (Boss*)self; - + if (b->health > 0) { b->facing = (world.bob->x < b->x) ? FACING_LEFT : FACING_RIGHT; @@ -117,14 +117,14 @@ static void tick(void) static void lookForPlayer(void) { float distance; - + self->thinkTime = rrnd(0, FPS / 2); if (rand() % 100 < 5) { brakingTimer = rrnd(60, 120); } - + distance = getDistance(world.bob->x, world.bob->y, self->x, self->y); if (distance > app.config.winHeight) @@ -132,7 +132,7 @@ static void lookForPlayer(void) moveTowardsPlayer(1); return; } - + if (!enemyCanSeePlayer(self)) { moveTowardsPlayer(1); @@ -143,7 +143,7 @@ static void lookForPlayer(void) { selectWeapon(); } - + if (distance < app.config.winHeight / 4) { moveTowardsPlayer(-6); @@ -157,9 +157,9 @@ static void lookForPlayer(void) static void selectWeapon(void) { Boss *b; - + b = (Boss*)self; - + if (world.bob->isOnGround || fabs(self->y - world.bob->y) > 64) { b->weaponType = WPN_AIMED_PISTOL; @@ -188,9 +188,9 @@ static void walk(void) static void moveTowardsPlayer(int dir) { float vel; - + vel = 0.5 * dir; - + if (brakingTimer == 0) { if (world.bob->x < self->x) @@ -221,9 +221,9 @@ static void moveTowardsPlayer(int dir) static void preFire(void) { Boss *b; - + b = (Boss*)self; - + if (b->reload > 0) { return; @@ -242,11 +242,11 @@ static void preFire(void) static void attack(void) { Boss *b; - + if (self->facing != FACING_DIE) { b = (Boss*)self; - + switch (b->weaponType) { case WPN_AIMED_PISTOL: @@ -270,9 +270,9 @@ static void attackPistol(void) float dx, dy; Bullet *bullet; Boss *b; - + b = (Boss*)self; - + bx = world.bob->x + rrnd(-8, 24); by = world.bob->y + rrnd(-8, 24); @@ -297,9 +297,9 @@ static void attackPlasma(void) { Boss *b; Bullet *bullet; - + b = (Boss*)self; - + bullet = createBaseBullet((Unit*)self, plasmaSprite[0]->w); bullet->facing = self->facing; bullet->damage = 2; @@ -320,9 +320,9 @@ static void attackMissile(void) { Boss *b; Bullet *missile; - + b = (Boss*)self; - + missile = createBaseBullet((Unit*)self, missileSprite[0]->w); missile->facing = b->facing; missile->dx = b->facing == FACING_RIGHT ? 15 : -15; @@ -330,7 +330,7 @@ static void attackMissile(void) missile->health = FPS * 3; missile->sprite[0] = missileSprite[0]; missile->sprite[1] = missileSprite[1]; - + initMissile(missile); b->reload = 15; @@ -352,9 +352,9 @@ static void applyDamage(int amount) static void die(void) { Boss *b; - + b = (Boss*)self; - + b->dx = (randF() - randF()) * 3; b->spriteTime = 0; @@ -379,9 +379,9 @@ static void die(void) static void die2() { Boss *b; - + b = (Boss*)self; - + if (b->isOnGround) { addTeleportStars(self); @@ -398,7 +398,7 @@ static void die2() awardTrophy("EYEDROID_COMMANDER"); game.stats[STAT_ENEMIES_KILLED]++; - + b->action = entityIdle; } } @@ -406,14 +406,14 @@ static void die2() static SDL_Rect *getCurrentSprite(void) { Sprite *s; - + s = (self->alive == ALIVE_ALIVE) ? self->sprite[self->facing] : self->sprite[FACING_DIE]; - + if (self->spriteFrame >= s->numFrames) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "WARNING: %s (%d) bad sprite frames - %d > %d\n", self->name, self->type, self->spriteFrame, s->numFrames); self->spriteFrame = 0; } - + return &s->frames[self->spriteFrame]->rect; } diff --git a/src/entities/boss/eyeDroidCommander.h b/src/entities/boss/eyeDroidCommander.h index 51718d0..667bc68 100644 --- a/src/entities/boss/eyeDroidCommander.h +++ b/src/entities/boss/eyeDroidCommander.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/boss/frost.c b/src/entities/boss/frost.c index 57baa04..77e3964 100644 --- a/src/entities/boss/frost.c +++ b/src/entities/boss/frost.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -23,16 +23,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Entity *initFrost(void) { Boss *b; - + b = initBlobBoss(); - + b->weakAgainst = ENV_LAVA; - + STRNCPY(b->name, "Frost", MAX_NAME_LENGTH); b->sprite[FACING_LEFT] = getSprite("FrostLeft"); b->sprite[FACING_RIGHT] = getSprite("FrostRight"); b->sprite[FACING_DIE] = getSprite("FrostSpin"); - + return (Entity*)b; } diff --git a/src/entities/boss/frost.h b/src/entities/boss/frost.h index 2b9e033..7def318 100644 --- a/src/entities/boss/frost.h +++ b/src/entities/boss/frost.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/boss/tankCommander.c b/src/entities/boss/tankCommander.c index d7931fa..ca55cab 100644 --- a/src/entities/boss/tankCommander.c +++ b/src/entities/boss/tankCommander.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -42,7 +42,7 @@ static Sprite *aimedSprite; Entity *initTankCommander(void) { Boss *b; - + b = initBoss(); STRNCPY(b->name, "Tank Commander", MAX_NAME_LENGTH); @@ -64,25 +64,25 @@ Entity *initTankCommander(void) b->getCollisionBounds = getCollisionBounds; brakingTimer = 0; - + aimedSprite = getSprite("AimedShot"); missileSprite[0] = getSprite("MissileRight"); missileSprite[1] = getSprite("MissileLeft"); tankTrack = initTankTrack(b); - + world.boss = b; - + return (Entity*)b; } static void activate(int activate) { Boss *b; - + b = (Boss*)self; - + b->flags &= ~EF_GONE; tankTrack->flags &= ~EF_GONE; @@ -97,9 +97,9 @@ static void activate(int activate) static void tick(void) { Boss *b; - + b = (Boss*)self; - + if (b->health > 0) { b->facing = (world.bob->x < b->x) ? FACING_LEFT : FACING_RIGHT; @@ -119,9 +119,9 @@ static void tick(void) static void lookForPlayer(void) { Boss *b; - + b = (Boss*)self; - + b->thinkTime = rrnd(0, FPS / 2); if (rand() % 10 == 0) @@ -175,9 +175,9 @@ static void moveTowardsPlayer(void) static void selectWeapon(void) { Boss *b; - + b = (Boss*)self; - + if (fabs(b->y - world.bob->y) > 64) { b->weaponType = WPN_AIMED_PISTOL; @@ -195,9 +195,9 @@ static void selectWeapon(void) static void preFire(void) { Boss *b; - + b = (Boss*)self; - + if (b->reload > 0) { moveTowardsPlayer(); @@ -217,11 +217,11 @@ static void preFire(void) static void attack(void) { Boss *b; - + if (self->facing != FACING_DIE) { b = (Boss*)self; - + switch (b->weaponType) { case WPN_AIMED_PISTOL: @@ -242,9 +242,9 @@ static void attackPistol(void) float dx, dy; Bullet *bullet; Boss *b; - + b = (Boss*)self; - + bx = world.bob->x + rrnd(-8, 24); by = world.bob->y + rrnd(-8, 24); @@ -271,7 +271,7 @@ static void attackMissile(void) { Bullet *missile; Boss *b; - + b = (Boss*)self; missile = createBaseBullet((Unit*)self, missileSprite[0]->w); @@ -287,7 +287,7 @@ static void attackMissile(void) missile->sprite[1] = missileSprite[1]; b->reload = 15; - + initMissile(missile); playBattleSound(SND_MISSILE, b->uniqueId % MAX_SND_CHANNELS, b->x, b->y); @@ -296,9 +296,9 @@ static void attackMissile(void) static void die1(void) { Boss *b; - + b = (Boss*)self; - + b->flags |= EF_BOUNCES; b->action = die2; @@ -312,7 +312,7 @@ static void die2(void) { int mx, my; Boss *b; - + b = (Boss*)self; b->health--; @@ -321,7 +321,7 @@ static void die2(void) { mx = (int) ((b->x + (b->w / 2)) / MAP_TILE_SIZE); my = (int) ((b->y + b->h) / MAP_TILE_SIZE); - + addScorchDecal(mx, my); addExplosion(b->x + rand() % b->w, b->y + rand() % b->h, 50, self); @@ -345,7 +345,7 @@ static void die2(void) awardTrophy("TANK_COMMANDER"); game.stats[STAT_ENEMIES_KILLED]++; - + b->action = entityIdle; } } diff --git a/src/entities/boss/tankCommander.h b/src/entities/boss/tankCommander.h index ff971a1..f45b2d3 100644 --- a/src/entities/boss/tankCommander.h +++ b/src/entities/boss/tankCommander.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/boss/tankTrack.c b/src/entities/boss/tankTrack.c index f5965cd..a650fa1 100644 --- a/src/entities/boss/tankTrack.c +++ b/src/entities/boss/tankTrack.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -31,7 +31,7 @@ static void getCollisionBounds(SDL_Rect *r); Entity *initTankTrack(Boss *owner) { Boss *b; - + b = initBoss(); superAnimate = b->animate; @@ -51,7 +51,7 @@ Entity *initTankTrack(Boss *owner) b->getCollisionBounds = getCollisionBounds; tankCommander = owner; - + return (Entity*)b; } diff --git a/src/entities/boss/tankTrack.h b/src/entities/boss/tankTrack.h index f55bb8a..ec6420b 100644 --- a/src/entities/boss/tankTrack.h +++ b/src/entities/boss/tankTrack.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/bullets/bullet.c b/src/entities/bullets/bullet.c index a404f09..918e875 100644 --- a/src/entities/bullets/bullet.c +++ b/src/entities/bullets/bullet.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -26,12 +26,12 @@ static void touch(Entity *other); Bullet *createBaseBullet(Unit *owner, int bulletWidth) { Bullet *bullet; - + bullet = malloc(sizeof(Bullet)); memset(bullet, 0, sizeof(Bullet)); initEntity((Entity*)bullet); - + bullet->x = owner->x + (owner->w / 2) - (bulletWidth / 2); bullet->y = (owner->y + owner->h / 2) - 3; bullet->dx = owner->facing == FACING_RIGHT ? 15 : -15; @@ -43,7 +43,7 @@ Bullet *createBaseBullet(Unit *owner, int bulletWidth) bullet->tick = tick; bullet->touch = touch; - + bullet->spriteFrame = 0; return bullet; @@ -104,7 +104,7 @@ static void touch(Entity *other) b->owner->type != other->type && !((b->owner->type == ET_TEEKA && other->type == ET_BOB) || (b->owner->type == ET_BOB && other->type == ET_TEEKA)) ); - + if (canHit) { swapSelf(other); diff --git a/src/entities/bullets/bullet.h b/src/entities/bullets/bullet.h index 302dcef..00e6065 100644 --- a/src/entities/bullets/bullet.h +++ b/src/entities/bullets/bullet.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/bullets/grenade.c b/src/entities/bullets/grenade.c index ec351fa..9807a5a 100644 --- a/src/entities/bullets/grenade.c +++ b/src/entities/bullets/grenade.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -30,7 +30,7 @@ static void explode(void); void initGrenade(Bullet *b) { b->flags = EF_BOUNCES | EF_IGNORE_BULLETS | EF_KILL_OFFSCREEN | EF_FRICTIONLESS | EF_NO_TELEPORT; - + superBounce = b->bounce; b->tick = tick; diff --git a/src/entities/bullets/grenade.h b/src/entities/bullets/grenade.h index bccc9d3..9db6ff6 100644 --- a/src/entities/bullets/grenade.h +++ b/src/entities/bullets/grenade.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/bullets/laser.c b/src/entities/bullets/laser.c index 4ac565b..683e051 100644 --- a/src/entities/bullets/laser.c +++ b/src/entities/bullets/laser.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -61,7 +61,7 @@ static void touch(Entity *other) b->owner->type != other->type && !((b->owner->type == ET_TEEKA && other->type == ET_BOB) || (b->owner->type == ET_BOB && other->type == ET_TEEKA)) ); - + if (canHit) { if (other->flags & EF_EXPLODES) diff --git a/src/entities/bullets/laser.h b/src/entities/bullets/laser.h index b64a642..557ff7a 100644 --- a/src/entities/bullets/laser.h +++ b/src/entities/bullets/laser.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/bullets/missile.c b/src/entities/bullets/missile.c index 83057ce..0dec491 100644 --- a/src/entities/bullets/missile.c +++ b/src/entities/bullets/missile.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/bullets/missile.h b/src/entities/bullets/missile.h index 818fff1..f2a3660 100644 --- a/src/entities/bullets/missile.h +++ b/src/entities/bullets/missile.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/cannons/cannon.c b/src/entities/cannons/cannon.c index ec5f702..0a95b2a 100644 --- a/src/entities/cannons/cannon.c +++ b/src/entities/cannons/cannon.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -32,11 +32,11 @@ static void getCollisionBounds(SDL_Rect *r); Entity *initCannon(void) { Unit *u; - + u = createUnit(); - + u->unitType = "Cannon"; - + u->type = ET_ENEMY; u->sprite[FACING_LEFT] = getSprite("CannonLeft"); @@ -62,7 +62,7 @@ Entity *initCannon(void) u->die = die; u->canFire = canFire; u->getCollisionBounds = getCollisionBounds; - + return (Entity*)u; } @@ -87,7 +87,7 @@ static void die(void) u->flags |= EF_BOUNCES | EF_ALWAYS_PROCESS; u->action = die2; - + u->facing = FACING_DIE; u->thinkTime = 0; u->spriteTime = 0; @@ -107,7 +107,7 @@ static void die2(void) { Unit *u; int mx, my; - + u = (Unit*)self; if (--u->health % 3 == 0) @@ -117,7 +117,7 @@ static void die2(void) addScorchDecal(mx, my); addExplosion(u->x, u->y, 50, self); - + throwDebris(u->x + u->w / 2, u->y + u->h / 2, 1); } @@ -130,7 +130,7 @@ static void die2(void) dropCarriedItem(); u->alive = ALIVE_DEAD; - + addRandomWeapon(u->x, u->y); } } @@ -146,7 +146,7 @@ static void lookForPlayer(void) { Unit *u; int r; - + u = (Unit*)self; u->thinkTime = rrnd(FPS / 2, FPS); @@ -192,9 +192,9 @@ static void lookForPlayer(void) static void preFire(void) { Unit *u; - + u = (Unit*)self; - + u->facing = (world.bob->x < u->x) ? FACING_LEFT : FACING_RIGHT; if (u->reload > 0) diff --git a/src/entities/cannons/cannon.h b/src/entities/cannons/cannon.h index 877465d..244ab1a 100644 --- a/src/entities/cannons/cannon.h +++ b/src/entities/cannons/cannon.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/decoration/debris.c b/src/entities/decoration/debris.c index 359dba1..acb68a8 100644 --- a/src/entities/decoration/debris.c +++ b/src/entities/decoration/debris.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -28,9 +28,9 @@ static void changeEnvironment(void); void initDebris(Decoration *d) { initEntity((Entity*)d); - + d->type = ET_DECORATION; - + d->effectType = rand() % 2; d->spriteFrame = 0; @@ -51,9 +51,9 @@ static void tick(void) static void action(void) { Decoration *d; - + d = (Decoration*)self; - + if (d->effectType == 0) { addFlameParticles(d->x + (rand() % d->w), d->y + (rand() % d->h), d->isOnGround); @@ -69,9 +69,9 @@ static void action(void) static void touch(Entity *other) { Decoration *d; - + d = (Decoration*)self; - + if (other == NULL) { d->dx *= 0.9; @@ -87,7 +87,7 @@ static void changeEnvironment(void) case ENV_WATER: self->alive = ALIVE_DEAD; break; - + default: break; } diff --git a/src/entities/decoration/debris.h b/src/entities/decoration/debris.h index b3914df..caed9cb 100644 --- a/src/entities/decoration/debris.h +++ b/src/entities/decoration/debris.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/decoration/fleshChunk.c b/src/entities/decoration/fleshChunk.c index c1985ff..7041395 100644 --- a/src/entities/decoration/fleshChunk.c +++ b/src/entities/decoration/fleshChunk.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -27,11 +27,11 @@ static void touch(Entity *other); void initFleshChunk(Decoration *d) { initEntity((Entity*)d); - + d->type = ET_DECORATION; d->flags |= EF_BOUNCES | EF_IGNORE_BULLETS | EF_NO_TELEPORT | EF_CRUSHABLE; - + if (app.config.blood != 2) { d->flags |= EF_KILL_OFFSCREEN; @@ -49,20 +49,20 @@ void initFleshChunk(Decoration *d) static void tick(void) { Decoration *d; - + d = (Decoration*)self; - + d->health--; - + d->bleedTime--; } static void action(void) { Decoration *d; - + d = (Decoration*)self; - + if (d->bleedTime > 0) { addBlood(d->x + (rand() % d->w), d->y + (rand() % d->h)); @@ -74,11 +74,11 @@ static void action(void) static void touch(Entity *other) { int mx, my; - + if (other == NULL) { self->dx *= 0.9; - + if (app.config.blood == 2) { mx = (int) ((self->x + (self->w / 2)) / MAP_TILE_SIZE); diff --git a/src/entities/decoration/fleshChunk.h b/src/entities/decoration/fleshChunk.h index e0d8983..da0c12f 100644 --- a/src/entities/decoration/fleshChunk.h +++ b/src/entities/decoration/fleshChunk.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/entity.c b/src/entities/entity.c index 0ef3fd6..bbcb003 100644 --- a/src/entities/entity.c +++ b/src/entities/entity.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -39,7 +39,7 @@ static void save(cJSON *root); void initEntity(Entity *e) { e->uniqueId = world.entityCounter++; - + e->environment = ENV_AIR; e->alive = ALIVE_ALIVE; @@ -55,10 +55,10 @@ void initEntity(Entity *e) e->flags = 0; e->thinkTime = 0; - + e->spriteFrame = -1; e->spriteTime = 0; - + e->init = init; e->reset = reset; e->action = action; @@ -72,10 +72,10 @@ void initEntity(Entity *e) e->die = die; e->changeEnvironment = changeEnvironment; e->getCollisionBounds = getCollisionBounds; - + e->load = load; e->save = save; - + world.entityTail->next = e; world.entityTail = e; } @@ -97,9 +97,9 @@ static void action(void) static void animate(void) { Sprite *s; - + s = self->sprite[self->facing]; - + if (self->spriteTime != -1) { if (--self->spriteTime <= 0) @@ -108,7 +108,7 @@ static void animate(void) { self->spriteFrame = 0; } - + self->spriteTime = self->sprite[self->facing]->times[self->spriteFrame]; } } @@ -169,15 +169,15 @@ void entityIdle(void) static SDL_Rect *getCurrentSprite(void) { Sprite *s; - + s = self->sprite[self->facing]; - + if (self->spriteFrame >= s->numFrames) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "WARNING: %s (%d) bad sprite frames - %d > %d\n", self->name, self->type, self->spriteFrame, s->numFrames); self->spriteFrame = 0; } - + return &s->frames[self->spriteFrame]->rect; } diff --git a/src/entities/entity.h b/src/entities/entity.h index 3377cd3..5fc83b6 100644 --- a/src/entities/entity.h +++ b/src/entities/entity.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/entityFactory.c b/src/entities/entityFactory.c index 652f83f..cfeab50 100644 --- a/src/entities/entityFactory.c +++ b/src/entities/entityFactory.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -31,7 +31,7 @@ void initEntityFactory(void) { memset(&head, 0, sizeof(EntityDef)); tail = &head; - + addEntityDef("AquaBlob", initAquaBlob); addEntityDef("PistolBlob", initPistolBlob); addEntityDef("PistolEyeDroid", initPistolDroid); @@ -54,11 +54,11 @@ void initEntityFactory(void) addEntityDef("Frost", initFrost); addEntityDef("EyeDroidCommander", initEyeDroidCommander); addEntityDef("TankCommander", initTankCommander); - + addEntityDef("Bob", initBob); addEntityDef("MIA", initMIA); addEntityDef("Teeka", initTeeka); - + addEntityDef("Item", initItem); addEntityDef("BronzeKey", initBronzeKey); addEntityDef("SilverKey", initSilverKey); @@ -69,10 +69,10 @@ void initEntityFactory(void) addEntityDef("YellowKeycard", initYellowKeycard); addEntityDef("WhiteKeycard", initWhiteKeycard); addEntityDef("WeaponPickup", initWeaponPickup); - + addEntityDef("Cell", initCell); addEntityDef("Heart", initHeart); - + addEntityDef("Exit", initExit); addEntityDef("PowerPool", initPowerPool); addEntityDef("Teleporter", initTeleporter); @@ -97,7 +97,7 @@ void initEntityFactory(void) Entity *createEntity(char *name) { EntityDef *def; - + for (def = head.next ; def != NULL ; def = def->next) { if (strcmp(def->name, name) == 0) @@ -106,22 +106,22 @@ Entity *createEntity(char *name) return def->initFunc(); } } - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "No such entity definition '%s'", name); exit(1); - + return NULL; } static void addEntityDef(char *name, Entity *(*initFunc)(void)) { EntityDef *def; - + def = malloc(sizeof(EntityDef)); memset(def, 0, sizeof(EntityDef)); tail->next = def; tail = def; - + STRNCPY(def->name, name, MAX_NAME_LENGTH); def->initFunc = initFunc; } @@ -131,11 +131,11 @@ static Entity *initGenericEvilBlob(void) int r; char name[MAX_NAME_LENGTH]; strcpy(name, ""); - + r = rand() % world.numEnemyTypes; - + sprintf(name, "%sBlob", world.enemyTypes[r]); - + return createEntity(name); } @@ -144,10 +144,10 @@ static Entity *initGenericEyeDroid(void) int r; char name[MAX_NAME_LENGTH]; strcpy(name, ""); - + r = rand() % world.numEnemyTypes; - + sprintf(name, "%sEyeDroid", world.enemyTypes[r]); - + return createEntity(name); } diff --git a/src/entities/entityFactory.h b/src/entities/entityFactory.h index 4ff18e6..0552e1c 100644 --- a/src/entities/entityFactory.h +++ b/src/entities/entityFactory.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/evilBlobs/aquaBlob.c b/src/entities/evilBlobs/aquaBlob.c index 9d76c22..5967e60 100644 --- a/src/entities/evilBlobs/aquaBlob.c +++ b/src/entities/evilBlobs/aquaBlob.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,9 +25,9 @@ static int canFire(Entity *target); Entity *initAquaBlob(void) { Unit *u; - + u = createEvilBlob(); - + u->unitType = "AquaBlob"; u->sprite[FACING_LEFT] = getSprite("AquaBlobLeft"); @@ -41,7 +41,7 @@ Entity *initAquaBlob(void) u->maxShotsToFire = 3; u->canFire = canFire; - + return (Entity*)u; } diff --git a/src/entities/evilBlobs/aquaBlob.h b/src/entities/evilBlobs/aquaBlob.h index fb03d17..d7a9081 100644 --- a/src/entities/evilBlobs/aquaBlob.h +++ b/src/entities/evilBlobs/aquaBlob.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/evilBlobs/evilBlob.c b/src/entities/evilBlobs/evilBlob.c index a8b517f..21dbe0d 100644 --- a/src/entities/evilBlobs/evilBlob.c +++ b/src/entities/evilBlobs/evilBlob.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -30,7 +30,7 @@ static void animate(void); Unit *createEvilBlob(void) { Unit *u; - + u = createUnit(); u->reload = 0; @@ -38,7 +38,7 @@ Unit *createEvilBlob(void) u->returnToStartTimer = 0; u->flags |= EF_HALT_AT_EDGE; - + superAnimate = u->animate; u->action = lookForPlayer; @@ -249,14 +249,14 @@ static void lookForPlayer(void) patrol(); return; } - + r = randF(); - + if (world.missionType == MT_OUTPOST || game.plus) { r = randF() * 0.65; } - + if (u->isMissionTarget) { r = randF() * 0.3; @@ -294,7 +294,7 @@ static void die(void) u->flags &= ~(EF_HALT_AT_EDGE | EF_GONE); u->action = die2; - + u->facing = FACING_DIE; u->thinkTime = 0; u->spriteTime = 0; @@ -331,8 +331,8 @@ static void animate(void) if (self->alive != ALIVE_ALIVE) { self->facing = FACING_DIE; - - superAnimate(); + + superAnimate(); } else if (self->dx != 0) { diff --git a/src/entities/evilBlobs/evilBlob.h b/src/entities/evilBlobs/evilBlob.h index d5531b1..65c99c5 100644 --- a/src/entities/evilBlobs/evilBlob.h +++ b/src/entities/evilBlobs/evilBlob.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/evilBlobs/grenadeBlob.c b/src/entities/evilBlobs/grenadeBlob.c index c735e3d..d025ff3 100644 --- a/src/entities/evilBlobs/grenadeBlob.c +++ b/src/entities/evilBlobs/grenadeBlob.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -27,18 +27,18 @@ static int canFire(Entity *target); Entity *initGrenadeBlob(void) { Unit *u; - + u = createEvilBlob(); u->unitType = "GrenadeBlob"; - + u->sprite[FACING_LEFT] = getSprite("GrenadeBlobLeft"); u->sprite[FACING_RIGHT] = getSprite("GrenadeBlobRight"); u->sprite[FACING_DIE] = getSprite("GrenadeBlobSpin"); u->weaponType = WPN_GRENADES; u->maxShotsToFire = 1; - + superPreFire = u->preFire; u->preFire = preFire; @@ -50,9 +50,9 @@ Entity *initGrenadeBlob(void) static void preFire(void) { Unit *u; - + u = (Unit*)self; - + superPreFire(); if (u->shotsToFire == 0) diff --git a/src/entities/evilBlobs/grenadeBlob.h b/src/entities/evilBlobs/grenadeBlob.h index cc1431d..5df572e 100644 --- a/src/entities/evilBlobs/grenadeBlob.h +++ b/src/entities/evilBlobs/grenadeBlob.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/evilBlobs/laserBlob.c b/src/entities/evilBlobs/laserBlob.c index 8cfcf6a..e81807d 100644 --- a/src/entities/evilBlobs/laserBlob.c +++ b/src/entities/evilBlobs/laserBlob.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,11 +25,11 @@ static int canFire(Entity *target); Entity *initLaserBlob(void) { Unit *u; - + u = createEvilBlob(); u->unitType = "LaserBlob"; - + u->sprite[FACING_LEFT] = getSprite("LaserBlobLeft"); u->sprite[FACING_RIGHT] = getSprite("LaserBlobRight"); u->sprite[FACING_DIE] = getSprite("LaserBlobSpin"); @@ -39,7 +39,7 @@ Entity *initLaserBlob(void) u->maxShotsToFire = 1; u->canFire = canFire; - + return (Entity*)u; } diff --git a/src/entities/evilBlobs/laserBlob.h b/src/entities/evilBlobs/laserBlob.h index cc1431d..5df572e 100644 --- a/src/entities/evilBlobs/laserBlob.h +++ b/src/entities/evilBlobs/laserBlob.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/evilBlobs/machineGunBlob.c b/src/entities/evilBlobs/machineGunBlob.c index 093a673..513735c 100644 --- a/src/entities/evilBlobs/machineGunBlob.c +++ b/src/entities/evilBlobs/machineGunBlob.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,11 +25,11 @@ static int canFire(Entity *target); Entity *initMachineGunBlob(void) { Unit *u; - + u = createEvilBlob(); - + u->unitType = "MachineGunBlob"; - + u->sprite[FACING_LEFT] = getSprite("MachineGunBlobLeft"); u->sprite[FACING_RIGHT] = getSprite("MachineGunBlobRight"); u->sprite[FACING_DIE] = getSprite("MachineGunBlobSpin"); @@ -39,7 +39,7 @@ Entity *initMachineGunBlob(void) u->maxShotsToFire = 5; u->canFire = canFire; - + return (Entity*)u; } diff --git a/src/entities/evilBlobs/machineGunBlob.h b/src/entities/evilBlobs/machineGunBlob.h index cc1431d..5df572e 100644 --- a/src/entities/evilBlobs/machineGunBlob.h +++ b/src/entities/evilBlobs/machineGunBlob.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/evilBlobs/pistolBlob.c b/src/entities/evilBlobs/pistolBlob.c index 996d17a..3db92b3 100644 --- a/src/entities/evilBlobs/pistolBlob.c +++ b/src/entities/evilBlobs/pistolBlob.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,11 +25,11 @@ static int canFire(Entity *target); Entity *initPistolBlob(void) { Unit *u; - + u = createEvilBlob(); - + u->unitType = "PistolBlob"; - + u->sprite[FACING_LEFT] = getSprite("PistolBlobLeft"); u->sprite[FACING_RIGHT] = getSprite("PistolBlobRight"); u->sprite[FACING_DIE] = getSprite("PistolBlobSpin"); @@ -39,7 +39,7 @@ Entity *initPistolBlob(void) u->maxShotsToFire = 3; u->canFire = canFire; - + return (Entity*)u; } diff --git a/src/entities/evilBlobs/pistolBlob.h b/src/entities/evilBlobs/pistolBlob.h index fb03d17..d7a9081 100644 --- a/src/entities/evilBlobs/pistolBlob.h +++ b/src/entities/evilBlobs/pistolBlob.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/evilBlobs/plasmaBlob.c b/src/entities/evilBlobs/plasmaBlob.c index 192615b..b266201 100644 --- a/src/entities/evilBlobs/plasmaBlob.c +++ b/src/entities/evilBlobs/plasmaBlob.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,11 +25,11 @@ static int canFire(Entity *target); Entity *initPlasmaBlob(void) { Unit *u; - + u = createEvilBlob(); - + u->unitType = "PlasmaBlob"; - + u->sprite[FACING_LEFT] = getSprite("PlasmaBlobLeft"); u->sprite[FACING_RIGHT] = getSprite("PlasmaBlobRight"); u->sprite[FACING_DIE] = getSprite("PlasmaBlobSpin"); @@ -39,7 +39,7 @@ Entity *initPlasmaBlob(void) u->maxShotsToFire = 6; u->canFire = canFire; - + return (Entity*)u; } diff --git a/src/entities/evilBlobs/plasmaBlob.h b/src/entities/evilBlobs/plasmaBlob.h index cc1431d..5df572e 100644 --- a/src/entities/evilBlobs/plasmaBlob.h +++ b/src/entities/evilBlobs/plasmaBlob.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/evilBlobs/shotgunBlob.c b/src/entities/evilBlobs/shotgunBlob.c index 2996747..8c51c7a 100644 --- a/src/entities/evilBlobs/shotgunBlob.c +++ b/src/entities/evilBlobs/shotgunBlob.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,11 +25,11 @@ static int canFire(Entity *target); Entity *initShotgunBlob(void) { Unit *u; - + u = createEvilBlob(); - + u->unitType = "ShotgunBlob"; - + u->sprite[FACING_LEFT] = getSprite("ShotgunBlobLeft"); u->sprite[FACING_RIGHT] = getSprite("ShotgunBlobRight"); u->sprite[FACING_DIE] = getSprite("ShotgunBlobSpin"); diff --git a/src/entities/evilBlobs/shotgunBlob.h b/src/entities/evilBlobs/shotgunBlob.h index fb03d17..d7a9081 100644 --- a/src/entities/evilBlobs/shotgunBlob.h +++ b/src/entities/evilBlobs/shotgunBlob.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/evilBlobs/spreadGunBlob.c b/src/entities/evilBlobs/spreadGunBlob.c index f36f909..9420bfc 100644 --- a/src/entities/evilBlobs/spreadGunBlob.c +++ b/src/entities/evilBlobs/spreadGunBlob.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,11 +25,11 @@ static int canFire(Entity *target); Entity *initSpreadGunBlob(void) { Unit *u; - + u = createEvilBlob(); u->unitType = "SpreadGunBlob"; - + u->sprite[FACING_LEFT] = getSprite("SpreadGunBlobLeft"); u->sprite[FACING_RIGHT] = getSprite("SpreadGunBlobRight"); u->sprite[FACING_DIE] = getSprite("SpreadGunBlobSpin"); @@ -39,7 +39,7 @@ Entity *initSpreadGunBlob(void) u->maxShotsToFire = 3; u->canFire = canFire; - + return (Entity*)u; } diff --git a/src/entities/evilBlobs/spreadGunBlob.h b/src/entities/evilBlobs/spreadGunBlob.h index cc1431d..5df572e 100644 --- a/src/entities/evilBlobs/spreadGunBlob.h +++ b/src/entities/evilBlobs/spreadGunBlob.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/eyeDroids/eyeDroid.c b/src/entities/eyeDroids/eyeDroid.c index ec2ed1c..c546283 100644 --- a/src/entities/eyeDroids/eyeDroid.c +++ b/src/entities/eyeDroids/eyeDroid.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -30,7 +30,7 @@ static void (*superTouch)(Entity *other); Unit *createEyeDroid(void) { Unit *u; - + u = createUnit(); u->flags |= EF_WEIGHTLESS | EF_HALT_AT_EDGE | EF_EXPLODES; @@ -222,12 +222,12 @@ static void lookForPlayer(void) } r = randF(); - + if (world.missionType == MT_OUTPOST || game.plus) { r = randF() * 0.65; } - + if (u->isMissionTarget) { r = randF() * 0.3; diff --git a/src/entities/eyeDroids/eyeDroid.h b/src/entities/eyeDroids/eyeDroid.h index c424a1c..ce7c960 100644 --- a/src/entities/eyeDroids/eyeDroid.h +++ b/src/entities/eyeDroids/eyeDroid.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/eyeDroids/grenadeDroid.c b/src/entities/eyeDroids/grenadeDroid.c index 26a07d5..1b7bf3a 100644 --- a/src/entities/eyeDroids/grenadeDroid.c +++ b/src/entities/eyeDroids/grenadeDroid.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -27,23 +27,23 @@ static int canFire(Entity *target); Entity *initGrenadeDroid(void) { Unit *u; - + u = createEyeDroid(); - + u->unitType = "GrenadeEyeDroid"; - + u->sprite[FACING_LEFT] = getSprite("GrenadeDroidLeft"); u->sprite[FACING_RIGHT] = getSprite("GrenadeDroidRight"); u->sprite[FACING_DIE] = getSprite("GrenadeDroidDie"); u->weaponType = WPN_GRENADES; u->maxShotsToFire = 1; - + superPreFire = u->preFire; u->preFire = preFire; u->canFire = canFire; - + return (Entity*)u; } diff --git a/src/entities/eyeDroids/grenadeDroid.h b/src/entities/eyeDroids/grenadeDroid.h index 34975f9..273cd72 100644 --- a/src/entities/eyeDroids/grenadeDroid.h +++ b/src/entities/eyeDroids/grenadeDroid.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/eyeDroids/laserDroid.c b/src/entities/eyeDroids/laserDroid.c index 483d9e6..daacbab 100644 --- a/src/entities/eyeDroids/laserDroid.c +++ b/src/entities/eyeDroids/laserDroid.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,9 +25,9 @@ static int canFire(Entity *target); Entity *initLaserDroid(void) { Unit *u; - + u = createEyeDroid(); - + u->unitType = "LaserEyeDroid"; u->sprite[FACING_LEFT] = getSprite("LaserDroidLeft"); @@ -39,7 +39,7 @@ Entity *initLaserDroid(void) u->maxShotsToFire = 1; u->canFire = canFire; - + return (Entity*)u; } diff --git a/src/entities/eyeDroids/laserDroid.h b/src/entities/eyeDroids/laserDroid.h index 34975f9..273cd72 100644 --- a/src/entities/eyeDroids/laserDroid.h +++ b/src/entities/eyeDroids/laserDroid.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/eyeDroids/machineGunDroid.c b/src/entities/eyeDroids/machineGunDroid.c index d61f747..03ba9cc 100644 --- a/src/entities/eyeDroids/machineGunDroid.c +++ b/src/entities/eyeDroids/machineGunDroid.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,9 +25,9 @@ static int canFire(Entity *target); Entity *initMachineGunDroid(void) { Unit *u; - + u = createEyeDroid(); - + u->unitType = "MachineGunEyeDroid"; u->sprite[FACING_LEFT] = getSprite("MachineGunDroidLeft"); @@ -39,7 +39,7 @@ Entity *initMachineGunDroid(void) u->maxShotsToFire = 5; u->canFire = canFire; - + return (Entity*)u; } diff --git a/src/entities/eyeDroids/machineGunDroid.h b/src/entities/eyeDroids/machineGunDroid.h index 34975f9..273cd72 100644 --- a/src/entities/eyeDroids/machineGunDroid.h +++ b/src/entities/eyeDroids/machineGunDroid.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/eyeDroids/pistolDroid.c b/src/entities/eyeDroids/pistolDroid.c index 61b2f7d..84d72df 100644 --- a/src/entities/eyeDroids/pistolDroid.c +++ b/src/entities/eyeDroids/pistolDroid.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,11 +25,11 @@ static int canFire(Entity *target); Entity *initPistolDroid(void) { Unit *u; - + u = createEyeDroid(); - + u->unitType = "PistolEyeDroid"; - + u->sprite[FACING_LEFT] = getSprite("PistolDroidLeft"); u->sprite[FACING_RIGHT] = getSprite("PistolDroidRight"); u->sprite[FACING_DIE] = getSprite("PistolDroidDie"); @@ -39,7 +39,7 @@ Entity *initPistolDroid(void) u->maxShotsToFire = 3; u->canFire = canFire; - + return (Entity*)u; } diff --git a/src/entities/eyeDroids/pistolDroid.h b/src/entities/eyeDroids/pistolDroid.h index b1c91e1..fd0fef8 100644 --- a/src/entities/eyeDroids/pistolDroid.h +++ b/src/entities/eyeDroids/pistolDroid.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/eyeDroids/plasmaDroid.c b/src/entities/eyeDroids/plasmaDroid.c index cf978b1..3729f66 100644 --- a/src/entities/eyeDroids/plasmaDroid.c +++ b/src/entities/eyeDroids/plasmaDroid.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,9 +25,9 @@ static int canFire(Entity *target); Entity *initPlasmaDroid(void) { Unit *u; - + u = createEyeDroid(); - + u->unitType = "PlasmaEyeDroid"; u->sprite[FACING_LEFT] = getSprite("PlasmaDroidLeft"); @@ -39,7 +39,7 @@ Entity *initPlasmaDroid(void) u->maxShotsToFire = 6; u->canFire = canFire; - + return (Entity*)u; } diff --git a/src/entities/eyeDroids/plasmaDroid.h b/src/entities/eyeDroids/plasmaDroid.h index 34975f9..273cd72 100644 --- a/src/entities/eyeDroids/plasmaDroid.h +++ b/src/entities/eyeDroids/plasmaDroid.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/eyeDroids/shotgunDroid.c b/src/entities/eyeDroids/shotgunDroid.c index c714b26..12b65e6 100644 --- a/src/entities/eyeDroids/shotgunDroid.c +++ b/src/entities/eyeDroids/shotgunDroid.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,9 +25,9 @@ static int canFire(Entity *target); Entity *initShotgunDroid(void) { Unit *u; - + u = createEyeDroid(); - + u->unitType = "ShotgunEyeDroid"; u->sprite[FACING_LEFT] = getSprite("ShotgunDroidLeft"); diff --git a/src/entities/eyeDroids/shotgunDroid.h b/src/entities/eyeDroids/shotgunDroid.h index b1c91e1..fd0fef8 100644 --- a/src/entities/eyeDroids/shotgunDroid.h +++ b/src/entities/eyeDroids/shotgunDroid.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/eyeDroids/spreadGunDroid.c b/src/entities/eyeDroids/spreadGunDroid.c index 49d63a5..e2accc3 100644 --- a/src/entities/eyeDroids/spreadGunDroid.c +++ b/src/entities/eyeDroids/spreadGunDroid.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,9 +25,9 @@ static int canFire(Entity *target); Entity *initSpreadGunDroid(void) { Unit *u; - + u = createEyeDroid(); - + u->unitType = "SpreadGunEyeDroid"; u->sprite[FACING_LEFT] = getSprite("SpreadGunDroidLeft"); @@ -39,7 +39,7 @@ Entity *initSpreadGunDroid(void) u->maxShotsToFire = 3; u->canFire = canFire; - + return (Entity*)u; } diff --git a/src/entities/eyeDroids/spreadGunDroid.h b/src/entities/eyeDroids/spreadGunDroid.h index 34975f9..273cd72 100644 --- a/src/entities/eyeDroids/spreadGunDroid.h +++ b/src/entities/eyeDroids/spreadGunDroid.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/items/battery.c b/src/entities/items/battery.c index d013a26..d2d3740 100644 --- a/src/entities/items/battery.c +++ b/src/entities/items/battery.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,23 +25,23 @@ static void touch(Entity *other); Item *initBattery(void) { Item *i; - + i = initConsumable(); - + i->spriteFrame = 0; i->spriteTime = -1; - + i->touch = touch; - + return i; } static void touch(Entity *other) { Item *i; - + i = (Item*)self; - + if (touchedPlayer(other)) { world.bob->power = MIN(world.bob->power + i->power, world.bob->powerMax); diff --git a/src/entities/items/battery.h b/src/entities/items/battery.h index e7da3b2..4985843 100644 --- a/src/entities/items/battery.h +++ b/src/entities/items/battery.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/items/cell.c b/src/entities/items/cell.c index 7b307e9..b9f5426 100644 --- a/src/entities/items/cell.c +++ b/src/entities/items/cell.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -26,9 +26,9 @@ static void init(void); Entity *initCell(void) { Item *i; - + i = (Item*)createItem(); - + i->type = ET_CELL; i->isMissionTarget = 1; @@ -42,7 +42,7 @@ Entity *initCell(void) i->init = init; i->touch = touch; - + return (Entity*)i; } diff --git a/src/entities/items/cell.h b/src/entities/items/cell.h index 00ece5f..2b01469 100644 --- a/src/entities/items/cell.h +++ b/src/entities/items/cell.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/items/cherry.c b/src/entities/items/cherry.c index f418b68..7021739 100644 --- a/src/entities/items/cherry.c +++ b/src/entities/items/cherry.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -25,20 +25,20 @@ static void touch(Entity *other); Item *initCherry(void) { Item *i; - + i = initConsumable(); - + i->touch = touch; - + return i; } static void touch(Entity *other) { Item *i; - + i = (Item*)self; - + if (touchedPlayer(other)) { world.bob->health = limit(world.bob->health + i->value, 0, world.bob->healthMax); diff --git a/src/entities/items/cherry.h b/src/entities/items/cherry.h index a1ea2f1..2e987a8 100644 --- a/src/entities/items/cherry.h +++ b/src/entities/items/cherry.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/items/consumable.c b/src/entities/items/consumable.c index 7f849ed..859b7da 100644 --- a/src/entities/items/consumable.c +++ b/src/entities/items/consumable.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -26,30 +26,30 @@ static void die(void); Item *initConsumable(void) { Item *i; - + i = malloc(sizeof(Item)); memset(i, 0, sizeof(Item)); - + initEntity((Entity*)i); - + i->type = ET_CONSUMABLE; - + i->flags |= EF_IGNORE_BULLETS | EF_CRUSHABLE; i->health = FPS * 10; i->tick = tick; i->die = die; - + return i; } static void tick(void) { Item *i; - + i = (Item*)self; - + if (i->isOnGround) { i->dx *= 0.05; @@ -75,9 +75,9 @@ int touchedPlayer(Entity *other) void pickupItem(void) { Item *i; - + i = (Item*)self; - + i->alive = (i->environment == ENV_AIR) ? ALIVE_DYING : ALIVE_DEAD; i->health = FPS / 2; i->thinkTime = 0; diff --git a/src/entities/items/consumable.h b/src/entities/items/consumable.h index 7da08cf..dff2b46 100644 --- a/src/entities/items/consumable.h +++ b/src/entities/items/consumable.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/items/heart.c b/src/entities/items/heart.c index 64c1b5a..d4dc57d 100644 --- a/src/entities/items/heart.c +++ b/src/entities/items/heart.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -27,9 +27,9 @@ static void init(void); Entity *initHeart(Entity *e) { Item *i; - + i = (Item*)createItem(); - + i->type = ET_HEART; i->isMissionTarget = 1; @@ -44,7 +44,7 @@ Entity *initHeart(Entity *e) i->action = action; i->init = init; i->touch = touch; - + return (Entity*)i; } diff --git a/src/entities/items/heart.h b/src/entities/items/heart.h index bd7b59a..930bea7 100644 --- a/src/entities/items/heart.h +++ b/src/entities/items/heart.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/items/item.c b/src/entities/items/item.c index ea873cf..103768d 100644 --- a/src/entities/items/item.c +++ b/src/entities/items/item.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -35,12 +35,12 @@ static void save(cJSON *root); Entity *createItem(void) { Item *i; - + i = malloc(sizeof(Item)); memset(i, 0, sizeof(Item)); - + initEntity((Entity*)i); - + i->type = ET_ITEM; STRNCPY(i->spriteName, "Weapon", MAX_NAME_LENGTH); @@ -62,7 +62,7 @@ Entity *createItem(void) i->die = die; i->load = load; i->save = save; - + return (Entity*)i; } @@ -74,18 +74,18 @@ Entity *initItem(void) static void init(void) { Item *i; - + i = (Item*)self; - + i->sprite[FACING_LEFT] = i->sprite[FACING_RIGHT] = i->sprite[FACING_DIE] = getSprite(i->spriteName); } static void reset(void) { Item *i; - + i = (Item*)self; - + self->x = i->startX; self->y = i->startY; } @@ -104,9 +104,9 @@ static void tick(void) static void touch(Entity *other) { Item *i; - + i = (Item*)self; - + if (i->alive == ALIVE_ALIVE && other != NULL && i->canBePickedUp) { if (other->type == ET_BOB && !world.bob->stunTimer) @@ -127,9 +127,9 @@ static void touch(Entity *other) static void bobPickupItem(void) { Item *i; - + i = (Item*)self; - + if (!i->isMissionTarget) { if (i->thinkTime == 0) @@ -158,7 +158,7 @@ static void bobPickupItem(void) updateObjective(i->name); i->collected = 1; } - + setGameplayMessage(MSG_STANDARD, app.strings[ST_PICKED_UP], i->name); playSound(SND_ITEM, i->uniqueId % MAX_SND_CHANNELS); @@ -185,9 +185,9 @@ static void bobPickupItem(void) static void enemyPickupItem(Unit *u) { Item *i; - + i = (Item*)self; - + if (u->canCarryItem && u->carriedItem == NULL && u->alive == ALIVE_ALIVE) { u->carriedItem = i; @@ -199,9 +199,9 @@ static void enemyPickupItem(Unit *u) static void destructablePickupItem(Structure *s) { Item *i; - + i = (Item*)self; - + if (s->carriedItem == NULL && s->alive == ALIVE_ALIVE) { s->carriedItem = i; @@ -213,9 +213,9 @@ static void destructablePickupItem(Structure *s) static void changeEnvironment(void) { Item *i; - + i = (Item*)self; - + if (i->environment == ENV_SLIME || i->environment == ENV_LAVA) { addTeleportStars(self); @@ -234,9 +234,9 @@ static void die(void) static void load(cJSON *root) { Item *i; - + i = (Item*)self; - + i->canBeCarried = cJSON_GetObjectItem(root, "canBeCarried")->valueint; i->canBePickedUp = cJSON_GetObjectItem(root, "canBePickedUp")->valueint; i->isMissionTarget = cJSON_GetObjectItem(root, "isMissionTarget")->valueint; @@ -247,7 +247,7 @@ static void load(cJSON *root) { i->collected = cJSON_GetObjectItem(root, "collected")->valueint; } - + if (game.plus & PLUS_MIRROR) { i->startX = MAP_PIXEL_WIDTH - i->startX; @@ -257,28 +257,28 @@ static void load(cJSON *root) static void save(cJSON *root) { Item *i; - + i = (Item*)self; - + switch (i->type) { case ET_KEY: cJSON_AddStringToObject(root, "type", i->sprite[0]->name); break; - + case ET_HEART: cJSON_AddStringToObject(root, "type", "Heart"); break; - + case ET_CELL: cJSON_AddStringToObject(root, "type", "Cell"); break; - + default: cJSON_AddStringToObject(root, "type", "Item"); break; } - + cJSON_AddNumberToObject(root, "canBeCarried", i->canBeCarried); cJSON_AddNumberToObject(root, "canBePickedUp", i->canBePickedUp); cJSON_AddNumberToObject(root, "isMissionTarget", i->isMissionTarget); diff --git a/src/entities/items/item.h b/src/entities/items/item.h index 5e8161f..78a60fe 100644 --- a/src/entities/items/item.h +++ b/src/entities/items/item.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/items/key.c b/src/entities/items/key.c index 5c0c9ce..2b34135 100644 --- a/src/entities/items/key.c +++ b/src/entities/items/key.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -23,41 +23,41 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Entity *initBronzeKey(Entity *e) { Item *i; - + i = (Item*)createItem(); - + i->type = ET_KEY; STRNCPY(i->name, "Bronze Key", MAX_NAME_LENGTH); STRNCPY(i->spriteName, "BronzeKey", MAX_NAME_LENGTH); - + return (Entity*)i; } Entity *initSilverKey(Entity *e) { Item *i; - + i = (Item*)createItem(); - + i->type = ET_KEY; STRNCPY(i->name, "Silver Key", MAX_NAME_LENGTH); STRNCPY(i->spriteName, "SilverKey", MAX_NAME_LENGTH); - + return (Entity*)i; } Entity *initGoldKey(Entity *e) { Item *i; - + i = (Item*)createItem(); - + i->type = ET_KEY; STRNCPY(i->name, "Gold Key", MAX_NAME_LENGTH); STRNCPY(i->spriteName, "GoldKey", MAX_NAME_LENGTH); - + return (Entity*)i; } diff --git a/src/entities/items/key.h b/src/entities/items/key.h index 550e089..5e5663e 100644 --- a/src/entities/items/key.h +++ b/src/entities/items/key.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/items/keycard.c b/src/entities/items/keycard.c index 8804a20..05c451b 100644 --- a/src/entities/items/keycard.c +++ b/src/entities/items/keycard.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -26,65 +26,65 @@ static void touchWhiteKeycard(Entity *other); Entity *initRedKeycard(void) { Item *i; - + i = (Item*)createItem(); - + i->type = ET_KEY; STRNCPY(i->name, "Red Keycard", MAX_NAME_LENGTH); STRNCPY(i->spriteName, "RedKeycard", MAX_NAME_LENGTH); - + return (Entity*)i; } Entity *initBlueKeycard(void) { Item *i; - + i = (Item*)createItem(); - + i->type = ET_KEY; STRNCPY(i->name, "Blue Keycard", MAX_NAME_LENGTH); STRNCPY(i->spriteName, "BlueKeycard", MAX_NAME_LENGTH); - + return (Entity*)i; } Entity *initGreenKeycard(void) { Item *i; - + i = (Item*)createItem(); - + i->type = ET_KEY; STRNCPY(i->name, "Green Keycard", MAX_NAME_LENGTH); STRNCPY(i->spriteName, "GreenKeycard", MAX_NAME_LENGTH); - + return (Entity*)i; } Entity *initYellowKeycard(void) { Item *i; - + i = (Item*)createItem(); - + i->type = ET_KEY; STRNCPY(i->name, "Yellow Keycard", MAX_NAME_LENGTH); STRNCPY(i->spriteName, "YellowKeycard", MAX_NAME_LENGTH); - + return (Entity*)i; } Entity *initWhiteKeycard(void) { Item *i; - + i = (Item*)createItem(); - + i->type = ET_KEY; STRNCPY(i->name, "White Keycard", MAX_NAME_LENGTH); @@ -93,7 +93,7 @@ Entity *initWhiteKeycard(void) itemTouch = i->touch; i->touch = touchWhiteKeycard; - + return (Entity*)i; } diff --git a/src/entities/items/keycard.h b/src/entities/items/keycard.h index b43ba9d..1751a2f 100644 --- a/src/entities/items/keycard.h +++ b/src/entities/items/keycard.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/items/weaponPickup.c b/src/entities/items/weaponPickup.c index 56014dc..51ec32a 100644 --- a/src/entities/items/weaponPickup.c +++ b/src/entities/items/weaponPickup.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -30,11 +30,11 @@ static void save(cJSON *root); Entity *initWeaponPickup(void) { Item *i; - + i = (Item*)initConsumable(); i->weaponType = WPN_PISTOL; - + superTick = i->tick; i->init = init; @@ -42,16 +42,16 @@ Entity *initWeaponPickup(void) i->touch = touch; i->load = load; i->save = save; - + return (Entity*)i; } static void init(void) { Item *i; - + i = (Item*)self; - + i->sprite[0] = i->sprite[1] = i->sprite[2] = getSprite("Weapon"); i->spriteFrame = i->weaponType; i->spriteTime = -1; @@ -65,9 +65,9 @@ static void init(void) static void tick(void) { Item *i; - + i = (Item*)self; - + superTick(); if (i->provided && i->alive == ALIVE_ALIVE) @@ -79,9 +79,9 @@ static void tick(void) static void touch(Entity *other) { Item *i; - + i = (Item*)self; - + if (touchedPlayer(other)) { world.bob->weaponType = i->weaponType; @@ -108,9 +108,9 @@ static void touch(Entity *other) static void load(cJSON *root) { Item *i; - + i = (Item*)self; - + i->weaponType = lookup(cJSON_GetObjectItem(root, "weaponType")->valuestring); i->provided = cJSON_GetObjectItem(root, "provided")->valueint; } diff --git a/src/entities/items/weaponPickup.h b/src/entities/items/weaponPickup.h index ff8b80a..7806f9d 100644 --- a/src/entities/items/weaponPickup.h +++ b/src/entities/items/weaponPickup.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/misc/destructable.c b/src/entities/misc/destructable.c index 42da282..893ab83 100644 --- a/src/entities/misc/destructable.c +++ b/src/entities/misc/destructable.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -30,11 +30,11 @@ static void save(cJSON *root); Entity *initDestructable(void) { Structure *s; - + s = createStructure(); - + s->type = ET_DESTRUCTABLE; - + s->isMissionTarget = 1; STRNCPY(s->spriteName, "Crate4", MAX_NAME_LENGTH); @@ -42,23 +42,23 @@ Entity *initDestructable(void) s->flags |= EF_EXPLODES; s->health = s->healthMax = 10; - + s->init = init; s->applyDamage = applyDamage; s->action = action; s->die = die; s->load = load; s->save = save; - + return (Entity*)s; } static void init(void) { Structure *s; - + s = (Structure*)self; - + s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite(s->spriteName); } @@ -74,9 +74,9 @@ static void action(void) { Structure *s; int mx, my; - + s = (Structure*)self; - + if (s->health <= 0) { s->health--; @@ -90,7 +90,7 @@ static void action(void) addExplosion(s->x, s->y, 50, self); s->dx = rrnd(-10, 10); s->dy = rrnd(-10, 10); - + throwDebris(s->x + s->w / 2, s->y + s->h / 2, 1); } @@ -112,19 +112,19 @@ static void action(void) static void die(void) { - + } static void load(cJSON *root) { Structure *s; - + s = (Structure*)self; - + s->health = cJSON_GetObjectItem(root, "health")->valueint; s->healthMax = cJSON_GetObjectItem(root, "healthMax")->valueint; STRNCPY(s->spriteName, cJSON_GetObjectItem(root, "spriteName")->valuestring, MAX_NAME_LENGTH); - + if (cJSON_GetObjectItem(root, "targetNames")) { STRNCPY(s->targetNames, cJSON_GetObjectItem(root, "targetNames")->valuestring, MAX_DESCRIPTION_LENGTH); @@ -134,9 +134,9 @@ static void load(cJSON *root) static void save(cJSON *root) { Structure *s; - + s = (Structure*)self; - + cJSON_AddStringToObject(root, "type", "Destructable"); cJSON_AddNumberToObject(root, "health", s->health); cJSON_AddNumberToObject(root, "healthMax", s->healthMax); diff --git a/src/entities/misc/destructable.h b/src/entities/misc/destructable.h index 1aa80bf..40394c7 100644 --- a/src/entities/misc/destructable.h +++ b/src/entities/misc/destructable.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/misc/infoPoint.c b/src/entities/misc/infoPoint.c index 2ab1182..9565ed5 100644 --- a/src/entities/misc/infoPoint.c +++ b/src/entities/misc/infoPoint.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -29,23 +29,23 @@ static void save(cJSON *root); Entity *initInfoPoint(void) { Structure *s; - + s = createStructure(); - + s->type = ET_INFO_POINT; - + s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("InfoPoint"); s->flags |= EF_WEIGHTLESS | EF_IGNORE_BULLETS | EF_NO_CLIP | EF_NO_ENVIRONMENT; - + s->ty = s->y; - + s->init = init; s->tick = tick; s->touch = touch; s->load = load; s->save = save; - + return (Entity*)s; } @@ -62,9 +62,9 @@ static void init(void) static void tick(void) { Structure *s; - + s = (Structure*)self; - + s->sinVal -= 0.05; s->y += (float) sin(s->sinVal) * 0.1; } @@ -72,9 +72,9 @@ static void tick(void) static void touch(Entity *other) { Structure *s; - + s = (Structure*)self; - + if (other == (Entity*)world.bob) { showInfoMessage(s->message); @@ -84,18 +84,18 @@ static void touch(Entity *other) static void load(cJSON *root) { Structure *s; - + s = (Structure*)self; - + STRNCPY(s->message, _(cJSON_GetObjectItem(root, "message")->valuestring), MAX_DESCRIPTION_LENGTH); } static void save(cJSON *root) { Structure *s; - + s = (Structure*)self; - + cJSON_AddStringToObject(root, "type", "InfoPoint"); cJSON_AddStringToObject(root, "message", s->message); } diff --git a/src/entities/misc/infoPoint.h b/src/entities/misc/infoPoint.h index fabe2fb..c3cc889 100644 --- a/src/entities/misc/infoPoint.h +++ b/src/entities/misc/infoPoint.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/structures/cardReader.c b/src/entities/structures/cardReader.c index 1666353..2a4f370 100644 --- a/src/entities/structures/cardReader.c +++ b/src/entities/structures/cardReader.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -30,33 +30,33 @@ static void save(cJSON *root); Entity *initCardReader(void) { Structure *s; - + s = createStructure(); - + s->type = ET_CARD_READER; - + s->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS | EF_NO_TELEPORT; STRNCPY(s->requiredItem, "Black Keycard", MAX_NAME_LENGTH); s->isStatic = 1; - + s->tick = tick; s->init = init; s->activate = activate; s->touch = touch; s->load = load; s->save = save; - + return (Entity*)s; } static void init(void) { Structure *s; - + s = (Structure*)self; - + if (!s->active) { s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("CardReaderIdle"); @@ -70,9 +70,9 @@ static void init(void) static void tick(void) { Structure *s; - + s = (Structure*)self; - + if (!s->active) { s->bobTouching = MAX(s->bobTouching - 1, 0); @@ -82,9 +82,9 @@ static void tick(void) static void touch(Entity *other) { Structure *s; - + s = (Structure*)self; - + if (!s->active && other->type == ET_BOB) { if (hasItem(s->requiredItem) || dev.cheatKeys) @@ -115,7 +115,7 @@ static void touch(Entity *other) static void activate(int active) { Structure *s; - + s = (Structure*)self; s->active = 1; @@ -127,9 +127,9 @@ static void activate(int active) static void load(cJSON *root) { Structure *s; - + s = (Structure*)self; - + if (cJSON_GetObjectItem(root, "active")) { s->active = cJSON_GetObjectItem(root, "active")->valueint; @@ -141,9 +141,9 @@ static void load(cJSON *root) static void save(cJSON *root) { Structure *s; - + s = (Structure*)self; - + cJSON_AddStringToObject(root, "type", "CardReader"); cJSON_AddNumberToObject(root, "active", s->active); cJSON_AddStringToObject(root, "requiredCard", s->requiredItem); diff --git a/src/entities/structures/cardReader.h b/src/entities/structures/cardReader.h index 712816a..aac99e1 100644 --- a/src/entities/structures/cardReader.h +++ b/src/entities/structures/cardReader.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/structures/door.c b/src/entities/structures/door.c index 5cda02a..7f49b0c 100644 --- a/src/entities/structures/door.c +++ b/src/entities/structures/door.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -34,13 +34,13 @@ static void save(cJSON *root); Entity *initDoor(void) { Structure *s; - + s = createStructure(); - + s->type = ET_DOOR; - + s->isSolid = 1; - + s->isStatic = 1; s->flags |= EF_WEIGHTLESS | EF_NO_ENVIRONMENT | EF_NO_CLIP | EF_EXPLODES | EF_NO_TELEPORT; @@ -54,23 +54,23 @@ Entity *initDoor(void) s->isLocked = 1; s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("Door"); - + s->init = init; s->tick = tick; s->touch = touch; s->activate = activate; s->load = load; s->save = save; - + return (Entity*)s; } static void init(void) { Structure *s; - + s = (Structure*)self; - + if (s->closedX == -1 && s->closedY == -1) { s->closedX = s->x; @@ -86,56 +86,56 @@ static void init(void) Entity *initBronzeDoor(void) { Structure *s; - + s = (Structure*)initDoor(); - + STRNCPY(s->requiredItem, "Bronze Key", MAX_NAME_LENGTH); s->speed = 2; s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("BronzeDoor"); - + return (Entity*)s; } Entity *initSilverDoor(void) { Structure *s; - + s = (Structure*)initDoor(); - + STRNCPY(s->requiredItem, "Silver Key", MAX_NAME_LENGTH); s->speed = 2; s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("SilverDoor"); - + return (Entity*)s; } Entity *initGoldDoor(void) { Structure *s; - + s = (Structure*)initDoor(); - + STRNCPY(s->requiredItem, "Gold Key", MAX_NAME_LENGTH); s->speed = 2; s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("GoldDoor"); - + return (Entity*)s; } static void tick(void) { Structure *s; - + s = (Structure*)self; - + s->dx = s->dy = 0; - + if (isOpening()) { getSlope(s->tx, s->ty, s->x, s->y, &s->dx, &s->dy); @@ -178,14 +178,14 @@ static void tick(void) static void touch(Entity *other) { Structure *s; - + s = (Structure*)self; - + if ((other->type != ET_BOB && s->isLocked) || (other->type != ET_BOB && other->type != ET_ENEMY)) { return; } - + if (s->isLocked && !dev.cheatKeys) { if (isClosed()) @@ -210,7 +210,7 @@ static void touch(Entity *other) return; } } - + if (s->state != DOOR_OPEN) { playBattleSound(SND_DOOR_START, s->uniqueId % MAX_SND_CHANNELS, s->x, s->y); @@ -222,9 +222,9 @@ static void touch(Entity *other) static void openWithKey(void) { Structure *s; - + s = (Structure*)self; - + if (hasItem(s->requiredItem) || dev.cheatKeys) { removeItem(s->requiredItem); @@ -240,10 +240,10 @@ static void openWithKey(void) } s->state = DOOR_OPEN; - + return; } - + if (s->thinkTime <= 0) { setGameplayMessage(MSG_GAMEPLAY, app.strings[ST_REQUIRED], s->requiredItem); @@ -257,28 +257,28 @@ static void openWithKey(void) static int isOpening(void) { Structure *s = (Structure*)self; - + return (s->state == DOOR_OPEN && ((int) s->x != (int) s->tx || (int) s->y != (int) s->ty)); } static int isClosing(void) { Structure *s = (Structure*)self; - + return (s->state == DOOR_CLOSED && ((int) s->x != s->closedX || (int) s->y != s->closedY)); } static int isClosed(void) { Structure *s = (Structure*)self; - + return (s->state == DOOR_CLOSED && ((int) s->x == s->closedX && (int) s->y == s->closedY)); } static void activate(int active) { Structure *s = (Structure*)self; - + s->state = (s->state == DOOR_CLOSED) ? DOOR_OPEN : DOOR_CLOSED; playBattleSound(SND_DOOR_START, s->uniqueId % MAX_SND_CHANNELS, s->x, s->y); @@ -297,9 +297,9 @@ static void activate(int active) static void load(cJSON *root) { Structure *s; - + s = (Structure*)self; - + s->isLocked = cJSON_GetObjectItem(root, "isLocked")->valueint; s->active = s->isLocked; if (cJSON_GetObjectItem(root, "requiredKey")) @@ -310,13 +310,13 @@ static void load(cJSON *root) s->ty = cJSON_GetObjectItem(root, "ty")->valueint; s->speed = cJSON_GetObjectItem(root, "speed")->valueint; s->state = lookup(cJSON_GetObjectItem(root, "state")->valuestring); - + if (cJSON_GetObjectItem(root, "closedX")) { s->closedX = cJSON_GetObjectItem(root, "closedX")->valueint; s->closedY = cJSON_GetObjectItem(root, "closedY")->valueint; } - + if (game.plus & PLUS_MIRROR) { s->tx = MAP_PIXEL_WIDTH - s->tx; @@ -326,9 +326,9 @@ static void load(cJSON *root) static void save(cJSON *root) { Structure *s; - + s = (Structure*)self; - + cJSON_AddStringToObject(root, "type", s->sprite[0]->name); cJSON_AddNumberToObject(root, "isLocked", s->isLocked); cJSON_AddNumberToObject(root, "tx", s->tx); @@ -338,7 +338,7 @@ static void save(cJSON *root) cJSON_AddNumberToObject(root, "speed", s->speed); cJSON_AddStringToObject(root, "state", getLookupName("DOOR_", s->state)); cJSON_AddStringToObject(root, "requiredKey", s->requiredItem); - + if (strcmp(s->sprite[0]->name, "Door") != 0) { cJSON_AddStringToObject(root, "type", s->sprite[0]->name); diff --git a/src/entities/structures/door.h b/src/entities/structures/door.h index 87bad5a..c0df699 100644 --- a/src/entities/structures/door.h +++ b/src/entities/structures/door.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/structures/exit.c b/src/entities/structures/exit.c index b2bec50..26ea8eb 100644 --- a/src/entities/structures/exit.c +++ b/src/entities/structures/exit.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -31,11 +31,11 @@ static void save(cJSON *root); Entity *initExit(void) { Structure *s; - + s = createStructure(); - + s->type = ET_EXIT; - + s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("Exit"); s->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS; @@ -45,7 +45,7 @@ Entity *initExit(void) s->active = 0; s->spriteTime = -1; - + s->init = init; s->tick = tick; s->action = action; @@ -53,7 +53,7 @@ Entity *initExit(void) s->getCollisionBounds = getCollisionBounds; s->load = load; s->save = save; - + return (Entity*)s; } @@ -74,9 +74,9 @@ static void init(void) static void tick(void) { Structure *s; - + s = (Structure*)self; - + if (!s->active) { s->bobTouching = MAX(s->bobTouching - 1, 0); @@ -87,9 +87,9 @@ static void action(void) { Objective *o; Structure *s; - + s = (Structure*)self; - + if (!s->active) { s->active = 1; @@ -114,9 +114,9 @@ static void action(void) static void touch(Entity *other) { Structure *s; - + s = (Structure*)self; - + if (other->type == ET_BOB && !world.isReturnVisit) { if (s->bobTouching == 0) @@ -150,18 +150,18 @@ static void getCollisionBounds(SDL_Rect *r) static void load(cJSON *root) { Structure *s; - + s = (Structure*)self; - + s->active = cJSON_GetObjectItem(root, "active")->valueint; } static void save(cJSON *root) { Structure *s; - + s = (Structure*)self; - + cJSON_AddStringToObject(root, "type", "Exit"); cJSON_AddNumberToObject(root, "active", s->active); } diff --git a/src/entities/structures/exit.h b/src/entities/structures/exit.h index 108ce54..8a0150c 100644 --- a/src/entities/structures/exit.h +++ b/src/entities/structures/exit.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/structures/horizontalDoor.c b/src/entities/structures/horizontalDoor.c index 31afcb7..e19617c 100644 --- a/src/entities/structures/horizontalDoor.c +++ b/src/entities/structures/horizontalDoor.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -23,12 +23,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Entity *initHorizontalDoor(void) { Structure *s; - + s = (Structure*)initDoor(); - + s->type = ET_DOOR; - + s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("HorizontalDoor"); - + return (Entity*)s; } diff --git a/src/entities/structures/horizontalDoor.h b/src/entities/structures/horizontalDoor.h index a1bba85..5595c15 100644 --- a/src/entities/structures/horizontalDoor.h +++ b/src/entities/structures/horizontalDoor.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/structures/itemPad.c b/src/entities/structures/itemPad.c index 2b3ff82..2800b1a 100644 --- a/src/entities/structures/itemPad.c +++ b/src/entities/structures/itemPad.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -30,24 +30,24 @@ static void save(cJSON *root); Entity *initItemPad(void) { Structure *s; - + s = createStructure(); - + s->type = ET_ITEM_PAD; - + s->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS; s->plane = PLANE_FOREGROUND; s->isStatic = 1; - + s->init = init; s->tick = tick; s->touch = touch; s->getCollisionBounds = getCollisionBounds; s->load = load; s->save = save; - + return (Entity*)s; } @@ -66,9 +66,9 @@ static void init(void) static void tick(void) { Structure *s; - + s = (Structure*)self; - + s->bobTouching = MAX(s->bobTouching - 1, 0); } @@ -76,9 +76,9 @@ static void touch(Entity *other) { Structure *s; Item *i; - + s = (Structure*)self; - + if (other->type == ET_BOB && !s->active) { i = getItem(s->requiredItem); @@ -86,14 +86,14 @@ static void touch(Entity *other) if (i != NULL) { removeItem(i->name); - + i->flags &= ~EF_GONE; - + i->x = s->x + (s->w / 2) - (i->w / 2); i->y = s->y - i->h; - + i->canBeCarried = i->canBePickedUp = i->isMissionTarget = 0; - + s->active = 1; setGameplayMessage(MSG_GAMEPLAY, app.strings[ST_REMOVED], s->requiredItem); @@ -103,7 +103,7 @@ static void touch(Entity *other) s->spriteFrame = 0; updateObjective(s->name); - + playBattleSound(SND_ITEM_PAD, s->uniqueId % MAX_SND_CHANNELS, s->x, s->y); } else if (!s->bobTouching) @@ -126,9 +126,9 @@ static void getCollisionBounds(SDL_Rect *r) static void load(cJSON *root) { Structure *s; - + s = (Structure*)self; - + if (cJSON_GetObjectItem(root, "active")) { s->active = cJSON_GetObjectItem(root, "active")->valueint; @@ -139,9 +139,9 @@ static void load(cJSON *root) static void save(cJSON *root) { Structure *s; - + s = (Structure*)self; - + cJSON_AddStringToObject(root, "type", "ItemPad"); cJSON_AddNumberToObject(root, "active", s->active); cJSON_AddStringToObject(root, "requiredItem", s->requiredItem); diff --git a/src/entities/structures/itemPad.h b/src/entities/structures/itemPad.h index f1ed392..f1f5300 100644 --- a/src/entities/structures/itemPad.h +++ b/src/entities/structures/itemPad.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/structures/lift.c b/src/entities/structures/lift.c index 6d68cbb..f9730ed 100644 --- a/src/entities/structures/lift.c +++ b/src/entities/structures/lift.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -29,11 +29,11 @@ static void save(cJSON *root); Entity *initLift(Entity *e) { Structure *s; - + s = createStructure(); - + s->type = ET_LIFT; - + s->state = LIFT_GOTO_FINISH; s->flags |= EF_WEIGHTLESS | EF_NO_ENVIRONMENT | EF_EXPLODES | EF_NO_CLIP | EF_ALWAYS_PROCESS | EF_NO_TELEPORT; @@ -47,22 +47,22 @@ Entity *initLift(Entity *e) s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("Lift"); s->active = 1; - + s->init = init; s->action = action; s->activate = activate; s->load = load; s->save = save; - + return (Entity*)s; } static void init(void) { Structure *s; - + s = (Structure*)self; - + if (s->startX == -1 && s->startY == -1) { s->startX = s->x; @@ -73,9 +73,9 @@ static void init(void) static void action(void) { Structure *s; - + s = (Structure*)self; - + s->dx = s->dy = 0; if (s->active) @@ -133,9 +133,9 @@ static void activate(int active) static void load(cJSON *root) { Structure *s; - + s = (Structure*)self; - + s->active = cJSON_GetObjectItem(root, "active")->valueint; s->tx = cJSON_GetObjectItem(root, "tx")->valueint; s->ty = cJSON_GetObjectItem(root, "ty")->valueint; @@ -144,7 +144,7 @@ static void load(cJSON *root) s->startX = cJSON_GetObjectItem(root, "startX")->valueint; s->startY = cJSON_GetObjectItem(root, "startY")->valueint; s->waitTime = cJSON_GetObjectItem(root, "waitTime")->valueint; - + if (game.plus & PLUS_MIRROR) { self->tx = MAP_PIXEL_WIDTH - self->tx; @@ -154,9 +154,9 @@ static void load(cJSON *root) static void save(cJSON *root) { Structure *s; - + s = (Structure*)self; - + cJSON_AddStringToObject(root, "type", "Lift"); cJSON_AddNumberToObject(root, "active", s->active); cJSON_AddNumberToObject(root, "tx", s->tx); diff --git a/src/entities/structures/lift.h b/src/entities/structures/lift.h index 382834c..bd61284 100644 --- a/src/entities/structures/lift.h +++ b/src/entities/structures/lift.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/structures/powerPoint.c b/src/entities/structures/powerPoint.c index de0e052..ee5a1f7 100644 --- a/src/entities/structures/powerPoint.c +++ b/src/entities/structures/powerPoint.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -30,9 +30,9 @@ static void save(cJSON *root); Entity *initPowerPoint(void) { Structure *s; - + s = createStructure(); - + s->type = ET_POWER_POINT; s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("PowerPoint"); @@ -42,23 +42,23 @@ Entity *initPowerPoint(void) s->requiredPower = 100; s->isStatic = 1; - + s->init = init; s->tick = tick; s->action = action; s->touch = touch; s->load = load; s->save = save; - + return (Entity*)s; } static void init(void) { Structure *s; - + s = (Structure*)self; - + if (s->requiredPower == 100 && game.cells != 0) { s->requiredPower = rrnd(game.cells * 0.7, game.cells * 0.9); @@ -73,9 +73,9 @@ static void init(void) static void tick(void) { Structure *s; - + s = (Structure*)self; - + if (!s->active) { s->bobTouching = MAX(s->bobTouching - 1, 0); @@ -92,24 +92,24 @@ static void tick(void) static void action(void) { Structure *s; - + s = (Structure*)self; - + s->spriteFrame = MIN(s->spriteFrame + 1, 3); if (!s->active && s->spriteFrame == 3) { activateEntities(s->targetNames, 1); - + setGameplayMessage(MSG_GAMEPLAY, s->message); - + if (!dev.cheatPower) { world.bob->power -= s->requiredPower; } - + s->requiredPower = 0; - + s->active = 1; } else @@ -121,9 +121,9 @@ static void action(void) static void touch(Entity *other) { Structure *s; - + s = (Structure*)self; - + if (!s->active && other->type == ET_BOB && other->dx == 0) { if (world.bob->power < s->requiredPower && s->bobTouching == 0 && !dev.cheatPower) @@ -140,9 +140,9 @@ static void touch(Entity *other) static void load(cJSON *root) { Structure *s; - + s = (Structure*)self; - + s->requiredPower = cJSON_GetObjectItem(root, "requiredPower")->valueint; STRNCPY(s->targetNames, cJSON_GetObjectItem(root, "targetNames")->valuestring, MAX_DESCRIPTION_LENGTH); } @@ -150,9 +150,9 @@ static void load(cJSON *root) static void save(cJSON *root) { Structure *s; - + s = (Structure*)self; - + cJSON_AddStringToObject(root, "type", "PowerPoint"); cJSON_AddNumberToObject(root, "requiredPower", s->requiredPower); cJSON_AddStringToObject(root, "targetNames", s->targetNames); diff --git a/src/entities/structures/powerPoint.h b/src/entities/structures/powerPoint.h index 2263e34..6a251df 100644 --- a/src/entities/structures/powerPoint.h +++ b/src/entities/structures/powerPoint.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/structures/powerPool.c b/src/entities/structures/powerPool.c index b343944..072af39 100644 --- a/src/entities/structures/powerPool.c +++ b/src/entities/structures/powerPool.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -30,11 +30,11 @@ static void save(cJSON *root); Entity *initPowerPool(void) { Structure *s; - + s = createStructure(); - + s->type = ET_POOL; - + s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("PowerPool"); s->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_IGNORE_BULLETS; @@ -42,14 +42,14 @@ Entity *initPowerPool(void) s->plane = PLANE_FOREGROUND; s->isStatic = 1; - + s->init = init; s->tick = tick; s->action = action; s->touch = touch; s->load = load; s->save = save; - + return (Entity*)s; } @@ -61,9 +61,9 @@ static void init(void) static void tick(void) { Structure *s; - + s = (Structure*)self; - + if (s->active) { s->spriteTime--; @@ -73,16 +73,16 @@ static void tick(void) s->spriteTime = 12; } } - + s->bobTouching = MAX(s->bobTouching - 1, 0); } static void action(void) { Structure *s; - + s = (Structure*)self; - + s->active = 1; if (s->spriteFrame == 0) @@ -97,18 +97,18 @@ static void action(void) static void touch(Entity *other) { Structure *s; - + s = (Structure*)self; - + if (s->active && other->type == ET_BOB && world.bob->power < world.bob->powerMax) { world.bob->power = MIN(world.bob->power + 0.05, world.bob->powerMax); - + if (s->bobTouching == 0) { playSound(SND_POWER_POOL, s->uniqueId % MAX_SND_CHANNELS); } - + s->bobTouching = 2; if (world.bob->power == world.bob->powerMax) diff --git a/src/entities/structures/powerPool.h b/src/entities/structures/powerPool.h index bc2ce8b..17146d5 100644 --- a/src/entities/structures/powerPool.h +++ b/src/entities/structures/powerPool.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/structures/pressurePlate.c b/src/entities/structures/pressurePlate.c index 330ce68..9a4c6b4 100644 --- a/src/entities/structures/pressurePlate.c +++ b/src/entities/structures/pressurePlate.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -29,11 +29,11 @@ static void save(cJSON *root); Entity *initPressurePlate(void) { Structure *s; - + s = createStructure(); - + s->type = ET_PRESSURE_PLATE; - + s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("PressurePlate"); s->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS; @@ -41,22 +41,22 @@ Entity *initPressurePlate(void) s->plane = PLANE_FOREGROUND; s->isStatic = 1; - + s->init = init; s->tick = tick; s->touch = touch; s->load = load; s->save = save; - + return (Entity*)s; } static void init(void) { Structure *s; - + s = (Structure*)self; - + if (s->active) { s->spriteTime = -1; @@ -72,9 +72,9 @@ static void init(void) static void tick(void) { Structure *s; - + s = (Structure*)self; - + if (s->isWeighted) { s->weightApplied = MAX(s->weightApplied - 1, 0); @@ -92,9 +92,9 @@ static void tick(void) static void touch(Entity *other) { Structure *s; - + s = (Structure*)self; - + if (other->type == ET_BOB || other->type == ET_PUSHBLOCK) { if (!s->active) @@ -113,9 +113,9 @@ static void touch(Entity *other) static void load(cJSON *root) { Structure *s; - + s = (Structure*)self; - + if (cJSON_GetObjectItem(root, "active")) { s->active = cJSON_GetObjectItem(root, "active")->valueint; @@ -127,9 +127,9 @@ static void load(cJSON *root) static void save(cJSON *root) { Structure *s; - + s = (Structure*)self; - + cJSON_AddStringToObject(root, "type", "PressurePlate"); cJSON_AddNumberToObject(root, "active", s->active); cJSON_AddNumberToObject(root, "isWeighted", s->isWeighted); diff --git a/src/entities/structures/pressurePlate.h b/src/entities/structures/pressurePlate.h index 22b6898..ae53d21 100644 --- a/src/entities/structures/pressurePlate.h +++ b/src/entities/structures/pressurePlate.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/structures/pushBlock.c b/src/entities/structures/pushBlock.c index 941870e..807ea75 100644 --- a/src/entities/structures/pushBlock.c +++ b/src/entities/structures/pushBlock.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -28,33 +28,33 @@ static void save(cJSON *root); Entity *initPushBlock(void) { Structure *s; - + s = createStructure(); - + s->type = ET_PUSHBLOCK; - + s->isSolid = 1; s->startX = s->startY = -1; - + s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("Crate1"); s->flags |= EF_EXPLODES | EF_ALWAYS_PROCESS; - + s->init = init; s->activate = activate; s->load = load; s->save = save; - + return (Entity*)s; } static void init(void) { Structure *s; - + s = (Structure*)self; - + sprintf(s->spriteName, "Crate%d", rrnd(1, 4)); s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite(s->spriteName); @@ -69,9 +69,9 @@ static void init(void) static void activate(int active) { Structure *s; - + s = (Structure*)self; - + if (active) { addTeleportStars(self); @@ -86,9 +86,9 @@ static void activate(int active) static void load(cJSON *root) { Structure *s; - + s = (Structure*)self; - + STRNCPY(s->spriteName, cJSON_GetObjectItem(root, "spriteName")->valuestring, MAX_NAME_LENGTH); s->startX = cJSON_GetObjectItem(root, "startX")->valueint; s->startY = cJSON_GetObjectItem(root, "startY")->valueint; @@ -97,9 +97,9 @@ static void load(cJSON *root) static void save(cJSON *root) { Structure *s; - + s = (Structure*)self; - + cJSON_AddStringToObject(root, "type", "PushBlock"); cJSON_AddStringToObject(root, "spriteName", s->spriteName); cJSON_AddNumberToObject(root, "startX", s->startX); diff --git a/src/entities/structures/pushBlock.h b/src/entities/structures/pushBlock.h index f841176..918ce40 100644 --- a/src/entities/structures/pushBlock.h +++ b/src/entities/structures/pushBlock.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/structures/structures.c b/src/entities/structures/structures.c index e74af89..0c0d176 100644 --- a/src/entities/structures/structures.c +++ b/src/entities/structures/structures.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -23,11 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Structure *createStructure(void) { Structure *s; - + s = malloc(sizeof(Structure)); memset(s, 0, sizeof(Structure)); - + initEntity((Entity*)s); - + return s; } diff --git a/src/entities/structures/structures.h b/src/entities/structures/structures.h index 7caefce..8316234 100644 --- a/src/entities/structures/structures.h +++ b/src/entities/structures/structures.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/structures/teleporter.c b/src/entities/structures/teleporter.c index e6d56e1..d0eef5b 100644 --- a/src/entities/structures/teleporter.c +++ b/src/entities/structures/teleporter.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -31,13 +31,13 @@ static void save(cJSON *root); Entity *initTeleporter(void) { Structure *s; - + s = createStructure(); - + s->type = ET_TELEPORTER; - + s->sprite[0] = s->sprite[1] = s->sprite[2] = getSprite("TeleporterActive"); - + s->flags |= EF_WEIGHTLESS | EF_NO_CLIP | EF_IGNORE_BULLETS | EF_NO_TELEPORT; s->plane = PLANE_FOREGROUND; @@ -45,7 +45,7 @@ Entity *initTeleporter(void) s->isStatic = 1; s->active = 1; - + s->init = init; s->action = action; s->touch = touch; @@ -53,16 +53,16 @@ Entity *initTeleporter(void) s->getCollisionBounds = getCollisionBounds; s->load = load; s->save = save; - + return (Entity*)s; } static void init(void) { Structure *s; - + s = (Structure*)self; - + if (s->active) { s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("TeleporterActive"); @@ -71,7 +71,7 @@ static void init(void) { s->sprite[FACING_LEFT] = s->sprite[FACING_RIGHT] = s->sprite[FACING_DIE] = getSprite("TeleporterInactive"); } - + s->spriteTime = 0; s->spriteFrame = 0; } @@ -89,7 +89,7 @@ static void action(void) static void touch(Entity *other) { float tx, ty; - + if (self->active && other != self && (other->flags & (EF_TELEPORTING | EF_NO_TELEPORT)) == 0) { tx = self->tx; @@ -134,13 +134,13 @@ static void getCollisionBounds(SDL_Rect *r) static void load(cJSON *root) { Structure *s; - + s = (Structure*)self; - + s->active = cJSON_GetObjectItem(root, "active")->valueint; s->tx = cJSON_GetObjectItem(root, "tx")->valueint; s->ty = cJSON_GetObjectItem(root, "ty")->valueint; - + if (game.plus & PLUS_MIRROR) { s->tx = MAP_PIXEL_WIDTH - s->tx; @@ -150,9 +150,9 @@ static void load(cJSON *root) static void save(cJSON *root) { Structure *s; - + s = (Structure*)self; - + cJSON_AddStringToObject(root, "type", "Teleporter"); cJSON_AddNumberToObject(root, "active", s->active); cJSON_AddNumberToObject(root, "tx", s->tx); diff --git a/src/entities/structures/teleporter.h b/src/entities/structures/teleporter.h index acdd242..f235f65 100644 --- a/src/entities/structures/teleporter.h +++ b/src/entities/structures/teleporter.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/traps/horizontalLaserTrap.c b/src/entities/traps/horizontalLaserTrap.c index 1a44fc6..8e22135 100644 --- a/src/entities/traps/horizontalLaserTrap.c +++ b/src/entities/traps/horizontalLaserTrap.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -23,10 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Entity *initHorizontalLaserTrap(void) { Entity *e; - + e = initLaserTrap(); - + e->sprite[0] = e->sprite[1] = e->sprite[2] = getSprite("HorizontalLaserTrap"); - + return e; } diff --git a/src/entities/traps/horizontalLaserTrap.h b/src/entities/traps/horizontalLaserTrap.h index 59e39a0..a316f57 100644 --- a/src/entities/traps/horizontalLaserTrap.h +++ b/src/entities/traps/horizontalLaserTrap.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/traps/laserTrap.c b/src/entities/traps/laserTrap.c index 55cb6b2..91092e8 100644 --- a/src/entities/traps/laserTrap.c +++ b/src/entities/traps/laserTrap.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -31,14 +31,14 @@ static void save(cJSON *root); Entity *initLaserTrap(void) { Trap *t; - + t = malloc(sizeof(Trap)); memset(t, 0, sizeof(Trap)); - + initEntity((Entity*)t); - + t->type = ET_TRAP; - + t->flags |= EF_WEIGHTLESS | EF_IGNORE_BULLETS | EF_NO_ENVIRONMENT | EF_NO_CLIP | EF_ALWAYS_PROCESS; t->onTime = FPS * 2; @@ -47,7 +47,7 @@ Entity *initLaserTrap(void) t->sprite[0] = t->sprite[1] = t->sprite[2] = getSprite("LaserTrap"); t->active = 1; - + t->init = init; t->tick = tick; t->action = action; @@ -55,7 +55,7 @@ Entity *initLaserTrap(void) t->activate = activate; t->load = load; t->save = save; - + return (Entity*)t; } @@ -70,9 +70,9 @@ static void init(void) static void tick(void) { Trap *t; - + t = (Trap*)self; - + if (!t->active && t->spriteTime == -1) { t->flags |= EF_GONE; @@ -82,9 +82,9 @@ static void tick(void) static void action(void) { Trap *t; - + t = (Trap*)self; - + if (t->offTime != 0) { if (!t->active) @@ -112,9 +112,9 @@ static void action(void) static void touch(Entity *other) { Trap *t; - + t = (Trap*)self; - + if (other != NULL && (other->type == ET_BOB || other->type == ET_ENEMY)) { if (!(other->flags & EF_IMMUNE)) @@ -123,7 +123,7 @@ static void touch(Entity *other) { other->dx = rrnd(-12, 12); other->dy = rrnd(-8, 0); - + if (t->offTime != 0) { swapSelf(other); @@ -137,10 +137,10 @@ static void touch(Entity *other) other->applyDamage((int) other->healthMax + 1); swapSelf(other); } - + playBattleSound(SND_FLESH_HIT, other->uniqueId % MAX_SND_CHANNELS, other->x, other->y); playBattleSound(SND_ELECTRIC_HIT, self->uniqueId % MAX_SND_CHANNELS, self->x, self->y); - + if (other->flags & EF_EXPLODES) { addSparkParticles(t->x, t->y); @@ -186,9 +186,9 @@ static void activate(int active) static void load(cJSON *root) { Trap *t; - + t = (Trap*)self; - + if (cJSON_GetObjectItem(root, "active")) { t->active = cJSON_GetObjectItem(root, "active")->valueint; @@ -200,9 +200,9 @@ static void load(cJSON *root) static void save(cJSON *root) { Trap *t; - + t = (Trap*)self; - + cJSON_AddStringToObject(root, "type", t->sprite[0]->name); cJSON_AddNumberToObject(root, "active", t->active); cJSON_AddNumberToObject(root, "onTime", t->onTime); diff --git a/src/entities/traps/laserTrap.h b/src/entities/traps/laserTrap.h index f05cf87..fb21fcd 100644 --- a/src/entities/traps/laserTrap.h +++ b/src/entities/traps/laserTrap.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/entities/unit.c b/src/entities/unit.c index 8bc7543..9d1fad4 100644 --- a/src/entities/unit.c +++ b/src/entities/unit.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -33,14 +33,14 @@ static void save(cJSON *root); Unit *createUnit(void) { Unit *u; - + u = malloc(sizeof(Unit)); memset(u, 0, sizeof(Unit)); - + initEntity((Entity*)u); - + u->type = ET_ENEMY; - + u->oxygen = MAX_OXYGEN; u->spriteTime = 0; @@ -57,22 +57,22 @@ Unit *createUnit(void) u->applyDamage = applyDamage; u->load = load; u->save = save; - + return u; } static void init(void) { Unit *u; - + u = (Unit*)self; - + if (u->startX == -1 && u->startY == -1) { u->startX = (int) u->x; u->startY = (int) u->y; } - + u->canCarryItem = rand() % 100 < 85; if (world.missionType == MT_OUTPOST) @@ -91,9 +91,9 @@ static void init(void) static void tick(void) { Unit *u; - + u = (Unit*)self; - + if (u->alive == ALIVE_ALIVE) { u->reload = limit(u->reload - 1, 0, FPS); @@ -158,9 +158,9 @@ static void reappear(void) if (self->x != 0 && self->y != 0) { self->y -= (self->h + 10); - + self->action = self->walk; - + self->flags &= ~(EF_GONE | EF_ALWAYS_PROCESS); addTeleportStars(self); @@ -176,9 +176,9 @@ static void reappear(void) static void applyDamage(int damage) { Unit *u; - + u = (Unit*)self; - + if (u->alive != ALIVE_DEAD) { if (u->health < 0) @@ -186,7 +186,7 @@ static void applyDamage(int damage) u->health = 0; u->alive = ALIVE_ALIVE; } - + u->health -= damage; if (u->health > 0) @@ -210,9 +210,9 @@ static void applyDamage(int damage) static void attack(void) { Unit *u; - + u = (Unit*)self; - + if (u->canFire((Entity*)world.bob)) { switch (u->weaponType) @@ -259,9 +259,9 @@ static void attack(void) static void preFire(void) { Unit *u; - + u = (Unit*)self; - + if (!(u->flags & EF_WEIGHTLESS)) { if (world.bob->y < u->y && u->isOnGround && rand() % 4 == 0) @@ -278,7 +278,7 @@ static void preFire(void) } u->attack(); - + if (--u->shotsToFire == 0) { u->action = u->walk; @@ -293,9 +293,9 @@ static int canFire(Entity *target) static SDL_Rect *getCurrentSprite(void) { Sprite *s; - + s = (self->alive == ALIVE_ALIVE) ? self->sprite[self->facing] : self->sprite[FACING_DIE]; - + if (self->spriteFrame >= s->numFrames) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "WARNING: %s (%d) bad sprite frames - %d > %d\n", self->name, self->type, self->spriteFrame, s->numFrames); @@ -308,9 +308,9 @@ static SDL_Rect *getCurrentSprite(void) static void load(cJSON *root) { Unit *u; - + u = (Unit*)self; - + u->canCarryItem = cJSON_GetObjectItem(root, "canCarryItem")->valueint; u->startX = cJSON_GetObjectItem(root, "startX")->valueint; u->startY = cJSON_GetObjectItem(root, "startY")->valueint; @@ -322,9 +322,9 @@ static void load(cJSON *root) static void save(cJSON *root) { Unit *u; - + u = (Unit*)self; - + cJSON_AddStringToObject(root, "type", u->unitType); cJSON_AddNumberToObject(root, "canCarryItem", u->canCarryItem); cJSON_AddNumberToObject(root, "startX", u->startX); diff --git a/src/entities/unit.h b/src/entities/unit.h index 946e9c6..1bcb046 100644 --- a/src/entities/unit.h +++ b/src/entities/unit.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/game/credits.h b/src/game/credits.h index e1f3732..8dede65 100644 --- a/src/game/credits.h +++ b/src/game/credits.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/game/ending.c b/src/game/ending.c index ae542dc..5c1865f 100644 --- a/src/game/ending.c +++ b/src/game/ending.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -34,21 +34,21 @@ static int endingTimer; void initEnding(void) { startSectionTransition(); - + background[0] = getImageFromAtlas("gfx/ending/ending01.jpg"); background[1] = getImageFromAtlas("gfx/ending/ending02.jpg"); - + atlasTexture = getTexture("gfx/atlas/atlas.png"); - + loadEndingText(); - + endingTextIndex = 0; endingImageIndex = 0; endingTimer = strlen(endingText[endingTextIndex]) * 4; - + app.delegate.logic = &logic; app.delegate.draw = &draw; - + endSectionTransition(); } @@ -64,7 +64,7 @@ static void logic(void) startSectionTransition(); endSectionTransition(); } - + if (endingTextIndex < NUM_ENDING_LINES) { endingTimer = strlen(endingText[endingTextIndex]) * 4; @@ -72,7 +72,7 @@ static void logic(void) else { fadeMusic(3000); - + endingTimer = FPS * 4; } } @@ -87,11 +87,11 @@ static void draw(void) { float h; int th; - + h = (app.config.winWidth / 800.0) * background[endingImageIndex]->rect.h; - + blitRectScaled(atlasTexture->texture, 0, app.config.winHeight - h, app.config.winWidth, h, &background[endingImageIndex]->rect, 0); - + if (endingTimer > 0 && endingTextIndex < NUM_ENDING_LINES) { app.textWidth = (app.config.winWidth / 2); @@ -106,21 +106,21 @@ static void loadEndingText(void) { int i; char *text, *line; - + i = 0; - + memset(endingText, 0, sizeof(NUM_ENDING_LINES * MAX_DESCRIPTION_LENGTH)); - + text = readFile("data/misc/ending.txt"); - + line = strtok(text, "\n"); - + while (line) { strncpy(endingText[i++], _(line), MAX_DESCRIPTION_LENGTH); - + line = strtok(NULL, "\n"); } - + free(text); } diff --git a/src/game/ending.h b/src/game/ending.h index 4d4b451..e4e2675 100644 --- a/src/game/ending.h +++ b/src/game/ending.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/game/game.c b/src/game/game.c index a0eecf0..5b4669f 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -28,31 +28,31 @@ void destroyGame(void); void initGame(void) { memset(&game, 0, sizeof(Game)); - + game.missionStatusTail = &game.missionStatusHead; game.trophyTail = &game.trophyHead; - + game.cells = 5; game.hearts = 10; game.stats[STAT_TIME_PLAYED] = 0; - + loadMetaInfo(); - + loadTrophyData(); } void newGame(void) { destroyGame(); - + initGame(); } int addItem(Item *item, int num) { int i; - + for (i = 0 ; i < MAX_ITEMS ; i++) { if (item->type == ET_KEY && world.bob->items[i] != NULL && world.bob->items[i]->type == ET_KEY && strcmp(item->name, world.bob->items[i]->name) == 0) @@ -71,13 +71,13 @@ int addItem(Item *item, int num) { item->value = num; } - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Added %s (value=%d)", item->name, world.bob->items[i]->value); - + return 1; } } - + return 0; } @@ -89,13 +89,13 @@ int hasItem(char *name) for (i = 0 ; i < MAX_ITEMS ; i++) { item = world.bob->items[i]; - + if (item != NULL && strcmp(item->name, name) == 0) { return 1; } } - + return 0; } @@ -103,17 +103,17 @@ Item *getItem(char *name) { int i; Item *item; - + for (i = 0 ; i < MAX_ITEMS ; i++) { item = world.bob->items[i]; - + if (item != NULL && strcmp(item->name, name) == 0) { return world.bob->items[i]; } } - + return NULL; } @@ -121,11 +121,11 @@ void removeItem(char *name) { int i; Item *item; - + for (i = 0 ; i < MAX_ITEMS ; i++) { item = world.bob->items[i]; - + if (item != NULL && strcmp(item->name, name) == 0) { /* only null this, as whether to kill it is handled elsewhere */ @@ -156,7 +156,7 @@ void dropCarriedItems(void) Item *item; memset(game.keys, 0, sizeof(Tuple) * MAX_KEY_TYPES); - + for (i = 0 ; i < MAX_ITEMS ; i++) { item = world.bob->items[i]; @@ -177,11 +177,11 @@ void dropCarriedItems(void) item->collected = 1; item->canBeCarried = 1; item->canBePickedUp = 1; - + /* items can only be collected if they have a thinktime of 0 */ item->thinkTime = FPS * 9999; } - + world.bob->items[i] = NULL; } } @@ -202,7 +202,7 @@ static void addKeyToStash(Item *item) t->value.i = item->value; SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Added %s (x%d) to stash", t->key, t->value.i); - + return; } } @@ -238,7 +238,7 @@ void addKeysFromStash(void) int getMissionStatus(char *id) { Tuple *t; - + for (t = game.missionStatusHead.next ; t != NULL ; t = t->next) { if (strcmp(t->key, id) == 0) @@ -246,7 +246,7 @@ int getMissionStatus(char *id) return t->value.i; } } - + return MS_LOCKED; } @@ -254,21 +254,21 @@ static void loadMetaInfo(void) { cJSON *root; char *text; - + text = readFile("data/meta/meta.json"); root = cJSON_Parse(text); - + game.totalKeys = cJSON_GetObjectItem(root, "totalKeys")->valueint; game.totalTargets = cJSON_GetObjectItem(root, "totalTargets")->valueint; game.totalMIAs = cJSON_GetObjectItem(root, "totalMIAs")->valueint; game.totalHearts = cJSON_GetObjectItem(root, "totalHearts")->valueint; game.totalCells = cJSON_GetObjectItem(root, "totalCells")->valueint; - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Meta [keys=%d, targets=%d, mias=%d, hearts=%d, cells=%d]", game.totalKeys, game.totalTargets, game.totalMIAs, game.totalHearts, game.totalCells); - + cJSON_Delete(root); - + free(text); } @@ -279,11 +279,11 @@ void loadGame(int slot) int i; Tuple *t; Trophy *trophy; - + destroyGame(); - + initGame(); - + game.saveSlot = slot; filename = buildFormattedString("%s/%d/game.json", app.saveDir, game.saveSlot); @@ -291,18 +291,18 @@ void loadGame(int slot) if (fileExists(filename)) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Loading game '%s' ...", filename); - + text = readFile(filename); root = cJSON_Parse(text); - + if (root) { game.cells = cJSON_GetObjectItem(root, "cells")->valueint; game.hearts = cJSON_GetObjectItem(root, "hearts")->valueint; - + statsJSON = cJSON_GetObjectItem(root, "stats"); - + for (i = 0 ; i < STAT_MAX ; i++) { statName = getLookupName("STAT_", i); @@ -346,10 +346,10 @@ void loadGame(int slot) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "Corrupt save file: %s", filename); exit(1); } - + free(text); } - + free(filename); } @@ -426,7 +426,7 @@ void saveGame(int isTempFile) cJSON_Delete(root); free(out); - + free(filename); } @@ -443,11 +443,11 @@ void restoreGameState(void) filename = buildFormattedString("%s/%d/game.json", app.saveDir, game.saveSlot); SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Restoring game from '%s' ...", filename); - + text = readFile(filename); root = cJSON_Parse(text); - + game.cells = cJSON_GetObjectItem(root, "cells")->valueint; game.hearts = cJSON_GetObjectItem(root, "hearts")->valueint; @@ -470,16 +470,16 @@ void restoreGameState(void) } cJSON_Delete(root); - + free(text); - + free(filename); } char *getSaveWidgetLabel(char *filename) { static char label[MAX_NAME_LENGTH]; - + cJSON *root, *statsJSON; char *text, *statName; int i, gameDone, gameTotal, stats[STAT_MAX]; @@ -489,13 +489,13 @@ char *getSaveWidgetLabel(char *filename) text = readFile(filename); root = cJSON_Parse(text); - + if (root) { statsJSON = cJSON_GetObjectItem(root, "stats"); memset(stats, 0, sizeof(int) * STAT_MAX); - + for (i = 0 ; i < STAT_MAX ; i++) { statName = getLookupName("STAT_", i); @@ -507,13 +507,13 @@ char *getSaveWidgetLabel(char *filename) } cJSON_Delete(root); - + gameDone = stats[STAT_MIAS_RESCUED] + stats[STAT_TARGETS_DEFEATED] + stats[STAT_KEYS_FOUND] + stats[STAT_HEARTS_FOUND] + stats[STAT_CELLS_FOUND]; gameTotal = game.totalMIAs + game.totalTargets + game.totalKeys + game.totalHearts + game.totalCells; sprintf(label, "%d%%%% - %s", getPercent(gameDone, gameTotal), timeToString(stats[STAT_TIME_PLAYED], 1)); } - + free(text); return label; @@ -527,9 +527,9 @@ void deleteSaveSlot(int slot) path = buildFormattedString("%s/%d", app.saveDir, slot); filenames = getFileList(path, &numFiles); - + free(path); - + for (i = 0 ; i < numFiles ; i++) { path = buildFormattedString("%s/%d/%s", app.saveDir, slot, filenames[i]); @@ -541,7 +541,7 @@ void deleteSaveSlot(int slot) } free(filenames[i]); - + free(path); } @@ -552,7 +552,7 @@ static int sortItems(const void *a, const void *b) { Entity *e1 = *((Entity**)a); Entity *e2 = *((Entity**)b); - + if (!e1) { return 1; @@ -571,9 +571,9 @@ void destroyGame(void) { Tuple *t; Trophy *trophy; - + memset(game.keys, 0, sizeof(Tuple) * MAX_KEY_TYPES); - + while (game.missionStatusHead.next) { t = game.missionStatusHead.next; @@ -582,7 +582,7 @@ void destroyGame(void) free(t); } - + while (game.trophyHead.next) { trophy = game.trophyHead.next; diff --git a/src/game/game.h b/src/game/game.h index 45006d8..8c40b39 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/game/options.c b/src/game/options.c index d1b74b3..2e293c4 100644 --- a/src/game/options.c +++ b/src/game/options.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -51,15 +51,15 @@ static Atlas *background; void initOptions(void (*callback)(void)) { startSectionTransition(); - + section = SECTION_MAIN; - + returnFromOptions = callback; atlasTexture = getTexture("gfx/atlas/atlas.png"); - + background = getImageFromAtlas("gfx/main/options.png"); - + setGeneralOptions(); setControlOptions(); @@ -68,7 +68,7 @@ void initOptions(void (*callback)(void)) app.delegate.logic = &logic; app.delegate.draw = &draw; - + endSectionTransition(); } @@ -77,7 +77,7 @@ static void setGeneralOptions(void) soundVolumeWidget = getWidget("soundVolume", "options"); soundVolumeWidget->action = soundVolume; soundVolumeWidget->value[0] = app.config.soundVolume; - + musicVolumeWidget = getWidget("musicVolume", "options"); musicVolumeWidget->action = musicVolume; musicVolumeWidget->value[0] = app.config.musicVolume; @@ -89,22 +89,22 @@ static void setGeneralOptions(void) windowSizeWidget = getWidget("windowSize", "options"); windowSizeWidget->action = windowSize; setWindowSizeOption(); - + bloodGoreWidget = getWidget("bloodGore", "options"); bloodGoreWidget->action = bloodGore; bloodGoreWidget->value[0] = app.config.blood; - + trophyAlertWidget = getWidget("trophyAlert", "options"); trophyAlertWidget->action = trophyAlert; trophyAlertWidget->value[0] = app.config.trophyAlert; - + inventoryWidget = getWidget("inventory", "options"); inventoryWidget->action = inventory; inventoryWidget->value[0] = app.config.inventory; - + controlsWidget = getWidget("controls", "options"); controlsWidget->action = controls; - + getWidget("back", "options")->action = back; getWidget("back", "controls")->action = back; } @@ -137,7 +137,7 @@ static void setControlOptions(void) getWidget("jetpack", "controls")->value[0] = app.config.keyControls[CONTROL_JETPACK]; getWidget("pause", "controls")->value[0] = app.config.keyControls[CONTROL_PAUSE]; getWidget("map", "controls")->value[0] = app.config.keyControls[CONTROL_MAP]; - + getWidget("left", "controls")->value[1] = app.config.joypadControls[CONTROL_LEFT]; getWidget("right", "controls")->value[1] = app.config.joypadControls[CONTROL_RIGHT]; getWidget("up", "controls")->value[1] = app.config.joypadControls[CONTROL_UP]; @@ -157,9 +157,9 @@ static void logic(void) static void draw(void) { float h; - + h = (app.config.winWidth / 800.0) * background->rect.h; - + if (section == SECTION_MAIN) { drawText(app.config.winWidth / 2, 50, 40, TA_CENTER, colors.white, app.strings[ST_OPTIONS]); @@ -168,30 +168,30 @@ static void draw(void) { drawText(app.config.winWidth / 2, 50, 40, TA_CENTER, colors.white, app.strings[ST_CONTROLS]); } - + blitRectScaled(atlasTexture->texture, 0, app.config.winHeight - h, app.config.winWidth, h, &background->rect, 0); - + drawWidgets(); } static void soundVolume(void) { app.config.soundVolume = soundVolumeWidget->value[0]; - + Mix_Volume(-1, app.config.soundVolume); } static void musicVolume(void) { app.config.musicVolume = musicVolumeWidget->value[0]; - + Mix_VolumeMusic(app.config.musicVolume); } static void fullscreen(void) { app.config.fullscreen = fullscreenWidget->value[0]; - + SDL_SetWindowFullscreen(app.window, app.config.fullscreen? SDL_WINDOW_FULLSCREEN : 0); } @@ -202,16 +202,16 @@ static void windowSize(void) i = windowSizeWidget->value[0]; sscanf(windowSizeWidget->options[i], "%d x %d", &app.config.winWidth, &app.config.winHeight); - + SDL_SetWindowSize(app.window, app.config.winWidth, app.config.winHeight); - + app.uiOffset.x = (app.config.winWidth / 2) - (UI_WIDTH / 2); app.uiOffset.y = (app.config.winHeight / 2) - (UI_HEIGHT / 2); - + SDL_DestroyTexture(app.backBuffer); - + app.backBuffer = SDL_CreateTexture(app.renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, app.config.winWidth, app.config.winHeight); - + initBackground(); } @@ -233,9 +233,9 @@ static void inventory(void) static void controls(void) { section = SECTION_CONTROLS; - + playSound(SND_MENU_SELECT, 0); - + showWidgetGroup("controls"); } @@ -250,7 +250,7 @@ static void updateControlConfig(void) app.config.keyControls[CONTROL_JETPACK] = getWidget("jetpack", "controls")->value[0]; app.config.keyControls[CONTROL_MAP] = getWidget("map", "controls")->value[0]; app.config.keyControls[CONTROL_PAUSE] = getWidget("pause", "controls")->value[0]; - + app.config.joypadControls[CONTROL_LEFT] = getWidget("left", "controls")->value[1]; app.config.joypadControls[CONTROL_RIGHT] = getWidget("right", "controls")->value[1]; app.config.joypadControls[CONTROL_UP] = getWidget("up", "controls")->value[1]; @@ -273,7 +273,7 @@ static void back(void) returnFromOptions(); endSectionTransition(); break; - + case SECTION_CONTROLS: updateControlConfig(); playSound(SND_MENU_BACK, 0); diff --git a/src/game/options.h b/src/game/options.h index 77fc43b..214afd2 100644 --- a/src/game/options.h +++ b/src/game/options.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/game/stats.c b/src/game/stats.c index 3f3fca3..b437f56 100644 --- a/src/game/stats.c +++ b/src/game/stats.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -30,11 +30,11 @@ static Atlas *right; void initStats(void) { page = 0; - + maxPages = STAT_TIME_PLAYED; maxPages /= STATS_PER_PAGE; maxPages = ceil(maxPages); - + statDescription[STAT_MISSIONS_COMPLETE] = _("Missions complete"); statDescription[STAT_KEYS_FOUND] = _("Keys found"); statDescription[STAT_CELLS_FOUND] = _("Power cells found"); @@ -56,7 +56,7 @@ void initStats(void) statDescription[STAT_MISSIONS_PLAYED] = _("Missions played"); statDescription[STAT_PERCENT_COMPLETE] = _("Percent complete"); statDescription[STAT_TIME_PLAYED] = _("Time played"); - + atlasTexture = getTexture("gfx/atlas/atlas.png"); left = getImageFromAtlas("gfx/ui/left.png"); right = getImageFromAtlas("gfx/ui/right.png"); @@ -65,11 +65,11 @@ void initStats(void) void initStatsDisplay(void) { int gameDone, gameTotal; - + gameDone = game.stats[STAT_MISSIONS_COMPLETE] + game.stats[STAT_MIAS_RESCUED] + game.stats[STAT_TARGETS_DEFEATED] + game.stats[STAT_KEYS_FOUND] + game.stats[STAT_HEARTS_FOUND] + game.stats[STAT_CELLS_FOUND]; - + gameTotal = game.totalMissions + game.totalMIAs + game.totalTargets + game.totalKeys + game.totalHearts + game.totalCells; - + game.stats[STAT_SHOT_ACCURACY] = getPercent(game.stats[STAT_SHOTS_HIT], game.stats[STAT_SHOTS_FIRED]); game.stats[STAT_PERCENT_COMPLETE] = getPercent(gameDone, gameTotal); } @@ -91,7 +91,7 @@ void doStats(void) app.keyboard[SDL_SCANCODE_RIGHT] = 0; clearControl(CONTROL_RIGHT); } - + doWidgets(); } @@ -99,72 +99,72 @@ void drawStats(void) { int i, y, startIndex; SDL_Rect r; - + drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128); - + SDL_SetRenderTarget(app.renderer, app.uiBuffer); - + r.w = 500; r.h = 500; r.x = (UI_WIDTH / 2) - r.w / 2; r.y = (UI_HEIGHT / 2) - r.h / 2; - + drawRect(r.x, r.y, r.w, r.h, 0, 0, 0, 192); - + drawOutlineRect(r.x, r.y, r.w, r.h, 200, 200, 200, 255); - + drawText(UI_WIDTH / 2, r.y + 5, 28, TA_CENTER, colors.white, "Stats"); - + drawText(UI_WIDTH / 2, r.y + 45, 16, TA_CENTER, colors.lightGrey, "Page %d / %d", page + 1, (int)maxPages); - + if (page > 0) { blitRect(atlasTexture->texture, UI_WIDTH / 2 - 100, r.y + 25, &left->rect, 1); } - + if (page < maxPages - 1) { blitRect(atlasTexture->texture, UI_WIDTH / 2 + 100, r.y + 25, &right->rect, 1); } - + SDL_SetRenderDrawColor(app.renderer, 128, 128, 128, 255); SDL_RenderDrawLine(app.renderer, r.x, r.y + 80, r.x + r.w, r.y + 80); - + y = 210; - + startIndex = (page * STATS_PER_PAGE); - + for (i = startIndex ; i < startIndex + STATS_PER_PAGE ; i++) { if (i < STAT_TIME_PLAYED) { drawText(r.x + 20, y, 18, TA_LEFT, colors.white, statDescription[i]); - + switch (i) { case STAT_SHOT_ACCURACY: case STAT_PERCENT_COMPLETE: drawText(r.x + r.w - 20, y, 18, TA_RIGHT, colors.white, "%d%%", game.stats[i]); break; - + case STAT_SWIM_TIME: case STAT_FLY_TIME: drawText(r.x + r.w - 20, y, 18, TA_RIGHT, colors.white, "%s", timeToString(game.stats[i] / FPS, 0)); break; - + default: drawText(r.x + r.w - 20, y, 18, TA_RIGHT, colors.white, "%d", game.stats[i]); break; } - + y += 40; } } - + drawText(r.x + 20, r.y + r.h - 95, 18, TA_LEFT, colors.white, statDescription[STAT_TIME_PLAYED]); drawText(r.x + r.w - 20, r.y + r.h - 95, 18, TA_RIGHT, colors.white, timeToString(game.stats[STAT_TIME_PLAYED], 1)); - + drawWidgets(); - + SDL_SetRenderTarget(app.renderer, app.backBuffer); } diff --git a/src/game/stats.h b/src/game/stats.h index 39b96f6..c510073 100644 --- a/src/game/stats.h +++ b/src/game/stats.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/game/title.c b/src/game/title.c index 39c77e4..cadfea8 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -54,11 +54,11 @@ static float titleAlpha; void initTitle(void) { startSectionTransition(); - + atlasTexture = getTexture("gfx/atlas/atlas.png"); - + title = getImageFromAtlas("gfx/main/title.png"); - + startNewGame = getWidget("new", "title"); startNewGame->action = &doNewGame; @@ -87,17 +87,17 @@ void initTitle(void) cancel = getWidget("cancel", "delete"); cancel->action = doCancel; - + titleAlpha = 0; - + continueGame->value[1] = getRecentSave(); - + showWidgetGroup("title"); - + if (continueGame->value[1] != -1) { setSelectedWidget("continue", "title"); - + load->disabled = 0; continueGame->disabled = 0; } @@ -106,32 +106,32 @@ void initTitle(void) load->disabled = 1; continueGame->disabled = 1; } - + saveAction = SA_NONE; - + app.delegate.logic = &logic; app.delegate.draw = &draw; - + loadMusic("music/Watching - DJ Sjors.ogg"); - + playMusic(0); - + endSectionTransition(); } static void logic(void) { doWidgets(); - + if (titleAlpha < 255) { titleAlpha++; } - + if (app.keyboard[SDL_SCANCODE_ESCAPE]) { doLoadCancel(); - + app.keyboard[SDL_SCANCODE_ESCAPE] = 0; } } @@ -141,14 +141,14 @@ static void draw(void) SDL_SetTextureAlphaMod(atlasTexture->texture, titleAlpha); blitRect(atlasTexture->texture, app.config.winWidth / 2, 175, &title->rect, 1); SDL_SetTextureAlphaMod(atlasTexture->texture, 255); - - drawText(10, app.config.winHeight - 30, 16, TA_LEFT, colors.white, "Copyright 2014, 2018 Parallel Realities"); + + drawText(10, app.config.winHeight - 30, 16, TA_LEFT, colors.white, "Copyright 2014, 2018-2019 Parallel Realities"); drawText(app.config.winWidth - 10, app.config.winHeight - 30, 16, TA_RIGHT, colors.white, "Version %.1f.%d", VERSION, REVISION); - + SDL_SetRenderTarget(app.renderer, app.uiBuffer); drawWidgets(); SDL_SetRenderTarget(app.renderer, app.backBuffer); - + if (saveAction == SA_NEW) { drawText(app.config.winWidth / 2, 275, 24, TA_CENTER, colors.white, app.strings[ST_CHOOSE_SAVE]); @@ -168,28 +168,28 @@ static int getRecentSave(void) { char *filename; int i, slot, curModTime, modTime; - + slot = -1; modTime = 0; - + for (i = 0 ; i < MAX_SAVE_SLOTS ; i++) { filename = buildFormattedString("%s/%d/game.json", app.saveDir, i); - + if (fileExists(filename)) { curModTime = getFileModTime(filename); - + if (curModTime > modTime) { modTime = curModTime; slot = i; } } - + free(filename); } - + return slot; } @@ -210,7 +210,7 @@ static void populateSaveSlotWidgets(void) { strcpy(save[i]->label, getSaveWidgetLabel(filename)); save[i]->value[0] = 1; - + if (strlen(save[i]->label) == 0) { STRNCPY(save[i]->label, app.strings[ST_CORRUPT_SAVE], MAX_NAME_LENGTH); @@ -222,11 +222,11 @@ static void populateSaveSlotWidgets(void) STRNCPY(save[i]->label, app.strings[ST_EMPTY_SAVE], MAX_NAME_LENGTH); save[i]->value[0] = 0; } - + save[i]->value[1] = i; save[i]->action = &doSaveSlot; - + free(filename); } } @@ -234,43 +234,43 @@ static void populateSaveSlotWidgets(void) static void doNewGame(void) { int i; - + saveAction = SA_NEW; - + showWidgetGroup("saveSlot"); - + for (i = 0 ; i < MAX_SAVE_SLOTS ; i++) { save[i]->disabled = 0; } - + loadCancel->visible = 1; - + destroyGame(); } static void doLoadGame(void) { int i; - + saveAction = SA_LOAD; - + showWidgetGroup("saveSlot"); - + for (i = 0 ; i < MAX_SAVE_SLOTS ; i++) { save[i]->disabled = save[i]->value[0] == 0; } - + loadCancel->visible = 1; } static void doContinueGame(void) { stopMusic(); - + loadGame(continueGame->value[1]); - + initHub(); } @@ -287,24 +287,24 @@ static void doCredits(void) static void doQuit(void) { stopMusic(); - + exit(1); } static void doSaveSlot(void) { Widget *w; - + w = getSelectedWidget(); - + game.saveSlot = w->value[1]; - + if (saveAction == SA_LOAD) { stopMusic(); - + loadGame(game.saveSlot); - + initHub(); } else if (saveAction == SA_NEW) @@ -316,9 +316,9 @@ static void doSaveSlot(void) else { saveAction = SA_DELETE; - + showWidgetGroup("delete"); - + setSelectedWidget("cancel", "delete"); } } @@ -327,26 +327,26 @@ static void doSaveSlot(void) static void doLoadCancel(void) { showWidgetGroup("title"); - + saveAction = SA_NONE; } static void doOK(void) { int saveSlot; - + saveSlot = game.saveSlot; - + deleteSaveSlot(saveSlot); - + stopMusic(); - + newGame(); - + initHub(); - + game.saveSlot = saveSlot; - + saveGame(0); } @@ -359,6 +359,6 @@ void returnToTitle(void) { app.delegate.logic = &logic; app.delegate.draw = &draw; - + showWidgetGroup("title"); } diff --git a/src/game/title.h b/src/game/title.h index 03f3228..b99826f 100644 --- a/src/game/title.h +++ b/src/game/title.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/game/trophies.c b/src/game/trophies.c index 3054298..0348b9a 100644 --- a/src/game/trophies.c +++ b/src/game/trophies.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -53,18 +53,18 @@ void initTrophies(void) alertSphere = getImageFromAtlas("gfx/trophies/alertSphere.png"); left = getImageFromAtlas("gfx/ui/left.png"); right = getImageFromAtlas("gfx/ui/right.png"); - + alertRect.h = 90; alertRect.y = 10; awarded = 0; - + sparkleAngle = 0; - + savedScreenshot = 0; - + page = 0; - + resetAlert(); } @@ -85,7 +85,7 @@ void doTrophies(void) app.keyboard[SDL_SCANCODE_RIGHT] = 0; clearControl(CONTROL_RIGHT); } - + doWidgets(); } @@ -94,42 +94,42 @@ void drawTrophies(void) Trophy *t; SDL_Rect r; int start, end, i, x, y; - + drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128); - + SDL_SetRenderTarget(app.renderer, app.uiBuffer); - + r.w = 600; r.h = 650; r.x = (UI_WIDTH / 2) - r.w / 2; r.y = (UI_HEIGHT / 2) - r.h / 2; - + r.y += 15; - + drawRect(r.x, r.y, r.w, r.h, 0, 0, 0, 192); - + drawOutlineRect(r.x, r.y, r.w, r.h, 200, 200, 200, 255); - + drawText(UI_WIDTH / 2, 60, 28, TA_CENTER, colors.white, app.strings[ST_TROPHIES]); - + drawText(UI_WIDTH / 2, 100, 16, TA_CENTER, colors.lightGrey, app.strings[ST_PAGE], page + 1, (int)maxPages); - + if (page > 0) { blitRect(atlasTexture->texture, UI_WIDTH / 2 - 100, 110, &left->rect, 1); } - + if (page < maxPages - 1) { blitRect(atlasTexture->texture, UI_WIDTH / 2 + 100, 110, &right->rect, 1); } - + x = r.x + 15; y = 160; start = page * TROPHIES_PER_PAGE; end = start + TROPHIES_PER_PAGE; i = 0; - + for (t = game.trophyHead.next ; t != NULL ; t = t->next) { if (i >= start && i < end) @@ -139,22 +139,22 @@ void drawTrophies(void) setSparkleColor(t); blitRectRotated(atlasTexture->texture, x + 32, y + 32, &sparkle->rect, sparkleAngle); blitRectRotated(atlasTexture->texture, x + 32, y + 32, &sparkle->rect, -sparkleAngle); - + blitRectScaled(atlasTexture->texture, x, y, 64, 64, &trophyIcons[t->value]->rect, 0); drawText(x + 85, y - 10, 20, TA_LEFT, colors.yellow, t->title); drawText(x + 85, y + 20, 18, TA_LEFT, colors.white, t->description); - + if (strlen(t->awardDateStr) == 0) { STRNCPY(t->awardDateStr, timeToDate(t->awardDate), MAX_NAME_LENGTH); } - + drawText(x + 85, y + 48, 18, TA_LEFT, colors.white, t->awardDateStr); } else { blitRectScaled(atlasTexture->texture, x, y, 64, 64, &trophyIcons[TROPHY_UNEARNED]->rect, 0); - + if (!t->hidden) { drawText(x + 85, y - 10, 20, TA_LEFT, colors.lightGrey, t->title); @@ -166,17 +166,17 @@ void drawTrophies(void) drawText(x + 85, y + 20, 20, TA_LEFT, colors.darkGrey, app.strings[ST_HIDDEN]); } } - + y += 120; } - + i++; } - + SDL_SetTextureColorMod(atlasTexture->texture, 255, 255, 255); - + drawWidgets(); - + SDL_SetRenderTarget(app.renderer, app.backBuffer); } @@ -270,7 +270,7 @@ void doTrophyAlerts(void) resetAlert(); } } - + sparkleAngle = mod(sparkleAngle + 0.25, 360); } } @@ -290,14 +290,14 @@ static void nextAlert(void) } } } - + if (alertTrophy) { playSound(SND_TROPHY, -1); - + calcTextDimensions(alertTrophy->title, 30, &alertRect.w, &h); calcTextDimensions(alertTrophy->description, 20, &w, &h); - + alertRect.w = MAX(alertRect.w, w); alertRect.w = MAX(400, alertRect.w); alertRect.w += 125; @@ -315,7 +315,7 @@ static void resetAlert(void) void drawTrophyAlert(void) { int x, y; - + if (alertTrophy) { drawRect(alertRect.x, alertRect.y, alertRect.w, alertRect.h, 0, 0, 0, 255); @@ -349,7 +349,7 @@ void loadTrophyData(void) text = readFile(filename); root = cJSON_Parse(text); - + numTrophies = 0; for (node = root->child ; node != NULL ; node = node->next) @@ -368,26 +368,26 @@ void loadTrophyData(void) { t->hidden = cJSON_GetObjectItem(node, "hidden")->valueint; } - + t->stat = -1; - + if (cJSON_GetObjectItem(node, "stat")) { t->stat = lookup(cJSON_GetObjectItem(node, "stat")->valuestring); t->statValue = cJSON_GetObjectItem(node, "statValue")->valueint; } - + numTrophies++; } cJSON_Delete(root); free(text); - + maxPages = numTrophies; maxPages /= TROPHIES_PER_PAGE; maxPages = ceil(maxPages); } - + static void setSparkleColor(Trophy *t) { switch (t->value) @@ -395,15 +395,15 @@ static void setSparkleColor(Trophy *t) case TROPHY_BRONZE: SDL_SetTextureColorMod(atlasTexture->texture, 255, 128, 0); break; - + case TROPHY_SILVER: SDL_SetTextureColorMod(atlasTexture->texture, 192, 192, 192); break; - + case TROPHY_GOLD: SDL_SetTextureColorMod(atlasTexture->texture, 255, 255, 0); break; - + case TROPHY_PLATINUM: SDL_SetTextureColorMod(atlasTexture->texture, 0, 128, 255); break; diff --git a/src/game/trophies.h b/src/game/trophies.h index 4da93aa..6912679 100644 --- a/src/game/trophies.h +++ b/src/game/trophies.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/hub/hub.c b/src/hub/hub.c index e06eef9..e4ef483 100644 --- a/src/hub/hub.c +++ b/src/hub/hub.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -69,24 +69,24 @@ void initHub(void) int unlockTeeka, i; HubMission *mission, *teeka; Tuple *t; - + startSectionTransition(); - + memset(&hubMissionHead, 0, sizeof(HubMission)); hubMissionTail = &hubMissionHead; - + memset(&keySprites, 0, sizeof(Sprite*) * MAX_KEY_TYPES); - + selectedMission = NULL; - + loadMusic("music/61321__mansardian__news-background.ogg"); - + atlasTexture = getTexture("gfx/atlas/atlas.png"); worldMap = getImageFromAtlas("gfx/hub/worldMap.jpg"); alert = getImageFromAtlas("gfx/hub/alert.png"); clouds = getTexture("gfx/hub/clouds.png"); cursorSpr = getSprite("Cursor"); - + for (i = 0 ; i < MAX_KEY_TYPES ; i++) { if (game.keys[i].value.i > 0) @@ -104,47 +104,47 @@ void initHub(void) getWidget("stats", "hub")->action = stats; getWidget("trophies", "hub")->action = trophies; getWidget("quit", "hub")->action = quit; - + getWidget("ok", "stats")->action = returnFromTrophyStats; getWidget("ok", "trophies")->action = returnFromTrophyStats; - + getWidget("startMission", "missionPlus")->action = startMissionPlus; getWidget("cancel", "missionPlus")->action = cancel; - + loadMissions(); - + if (dev.cheatLevels) { unlockAllMissions(); } - + game.totalMissions = 0; - + unlockedMissions = 0; - + game.stats[STAT_MISSIONS_COMPLETE] = 0; - + unlockTeeka = 1; - + blipValue = 0; - + doPlusSettings = 0; - + showing = SHOW_NONE; - + cursor.x = app.config.winWidth / 2; cursor.y = app.config.winHeight / 2; SDL_WarpMouseInWindow(app.window, cursor.x, cursor.y); game.isComplete = 0; - + for (t = game.missionStatusHead.next ; t != NULL ; t = t->next) { if (t->value.i != MS_INCOMPLETE) { unlockedMissions++; } - + if (t->value.i == MS_COMPLETE) { game.stats[STAT_MISSIONS_COMPLETE]++; @@ -157,20 +157,20 @@ void initHub(void) } } } - + teeka = NULL; - + unlockedMissions = 0; - + for (mission = hubMissionHead.next ; mission != NULL ; mission = mission->next) { if (requiredMissionUnlocked(mission->requires) || dev.cheatLevels || game.isComplete) { unlockMission(mission->id); } - + mission->status = getMissionStatus(mission->id); - + if (!game.isComplete) { if (strcmp(mission->id, "teeka") == 0) @@ -181,7 +181,7 @@ void initHub(void) { unlockTeeka = 0; } - + if (mission->status == MS_MISSING_HEART_CELL) { STRNCPY(mission->description, app.strings[ST_HEART_CELL], MAX_DESCRIPTION_LENGTH); @@ -191,21 +191,21 @@ void initHub(void) { STRNCPY(mission->description, app.strings[ST_FREEPLAY], MAX_DESCRIPTION_LENGTH); } - + game.totalMissions++; - + if (mission->status != MS_LOCKED) { unlockedMissions++; } } - + if (teeka != NULL) { if (unlockTeeka) { unlockMission("teeka"); - + teeka->status = MS_INCOMPLETE; } else @@ -215,30 +215,30 @@ void initHub(void) } awardMissionTrophies(); - + cloudPos.x = randF() - randF(); cloudPos.y = randF() - randF(); - + app.delegate.logic = &logic; app.delegate.draw = &draw; - + app.restrictTrophyAlert = 0; - + playMusic(1); - + endSectionTransition(); } static void logic(void) { blipValue += 0.1; - + blipSize = 64 + (sin(blipValue) * 16); - + scrollBackground(cloudPos.x, cloudPos.y); - + animateSprites(); - + switch (showing) { case SHOW_NONE: @@ -252,7 +252,7 @@ static void logic(void) doMissionInfo(); } break; - + case SHOW_WIDGETS: doWidgets(); if (app.keyboard[SDL_SCANCODE_ESCAPE]) @@ -262,7 +262,7 @@ static void logic(void) app.keyboard[SDL_SCANCODE_ESCAPE] = 0; } break; - + case SHOW_STATS: doStats(); if (app.keyboard[SDL_SCANCODE_ESCAPE]) @@ -271,7 +271,7 @@ static void logic(void) returnFromTrophyStats(); } break; - + case SHOW_TROPHIES: doTrophies(); if (app.keyboard[SDL_SCANCODE_ESCAPE]) @@ -280,7 +280,7 @@ static void logic(void) returnFromTrophyStats(); } break; - + default: break; } @@ -322,7 +322,7 @@ static void doCursor(void) static void doMissionSelect(void) { HubMission *m; - + if (app.keyboard[SDL_SCANCODE_ESCAPE]) { playSound(SND_MENU_BACK, 0); @@ -333,7 +333,7 @@ static void doMissionSelect(void) else if (isControl(CONTROL_FIRE) || app.mouse.button[SDL_BUTTON_LEFT]) { m = getMissionAt(cursor.x, cursor.y); - + if (m != NULL) { selectedMission = m; @@ -348,9 +348,9 @@ static void doMissionSelect(void) static void doMissionInfo(void) { Widget *w; - + w = selectWidgetAt(cursor.x - app.uiOffset.x, cursor.y - app.uiOffset.y); - + if ((w != NULL) && (isControl(CONTROL_FIRE) || app.mouse.button[SDL_BUTTON_LEFT])) { if (w->type == WT_BUTTON) @@ -362,11 +362,11 @@ static void doMissionInfo(void) /* assuming there are only two options */ w->value[0] = !w->value[0]; } - + app.mouse.button[SDL_BUTTON_LEFT] = 0; clearControl(CONTROL_FIRE); } - + if (app.keyboard[SDL_SCANCODE_ESCAPE]) { cancel(); @@ -376,13 +376,13 @@ static void doMissionInfo(void) static void draw(void) { blitRectScaled(atlasTexture->texture, 0, 0, app.config.winWidth, app.config.winHeight, &worldMap->rect, 0); - + drawBackground(clouds->texture); - + drawMissions(); - + drawInfoBar(); - + switch (showing) { case SHOW_NONE: @@ -396,7 +396,7 @@ static void draw(void) { drawPlusSettings(); } - + SDL_SetRenderTarget(app.renderer, app.uiBuffer); drawWidgets(); /* draw on both the UI buffer and main buffer, just to cheat */ @@ -405,15 +405,15 @@ static void draw(void) } blitRect(atlasTexture->texture, cursor.x, cursor.y, getCurrentFrame(cursorSpr), 1); break; - + case SHOW_WIDGETS: drawHudWidgets(); break; - + case SHOW_STATS: drawStats(); break; - + case SHOW_TROPHIES: drawTrophies(); break; @@ -424,11 +424,11 @@ static void drawMissions(void) { HubMission *mission; double ratioX, ratioY; - + /* the original Attrition is based on 800x600, so multiply up */ ratioX = app.config.winWidth / 800.0; ratioY = app.config.winHeight / 600.0; - + for (mission = hubMissionHead.next ; mission != NULL ; mission = mission->next) { switch (mission->status) @@ -438,134 +438,134 @@ static void drawMissions(void) blitRectScaled(atlasTexture->texture, mission->x * ratioX, mission->y * ratioY, blipSize, blipSize, &alert->rect, 1); drawText(mission->x * ratioX, (mission->y * ratioY) - 32, 18, TA_CENTER, colors.white, mission->name); break; - + case MS_PARTIAL: case MS_MISSING_HEART_CELL: SDL_SetTextureColorMod(atlasTexture->texture, 255, 255, 0); blitRectScaled(atlasTexture->texture, mission->x * ratioX, mission->y * ratioY, blipSize, blipSize, &alert->rect, 1); drawText(mission->x * ratioX, (mission->y * ratioY) - 32, 18, TA_CENTER, colors.white, mission->name); break; - + default: break; } } - + SDL_SetTextureColorMod(atlasTexture->texture, 255, 255, 255); } static void drawInfoBar(void) { int x; - + x = (50 + (app.config.winWidth - 50)) / 5; - + drawRect(0, 0, app.config.winWidth, 32, 0, 0, 0, 192); - + drawText(10, 5, 18, TA_LEFT, colors.white, app.strings[ST_HUB_MISSIONS], game.stats[STAT_MISSIONS_COMPLETE], unlockedMissions); - + drawText(x, 5, 18, TA_CENTER, colors.white, app.strings[ST_HUB_MIAS], game.stats[STAT_MIAS_RESCUED], game.totalMIAs); - + drawText(x * 2, 5, 18, TA_CENTER, colors.white, app.strings[ST_HUB_TARGETS], game.stats[STAT_TARGETS_DEFEATED], game.totalTargets); - + drawText(x * 3, 5, 18, TA_CENTER, colors.white, app.strings[ST_HUB_KEYS], game.stats[STAT_KEYS_FOUND], game.totalKeys); - + drawText(x * 4, 5, 18, TA_CENTER, colors.white, app.strings[ST_HUB_HEARTS], game.stats[STAT_HEARTS_FOUND], game.totalHearts); - + drawText(app.config.winWidth - 10, 5, 18, TA_RIGHT, colors.white, app.strings[ST_HUB_CELLS], game.stats[STAT_CELLS_FOUND], game.totalCells); } static void drawHudWidgets(void) { drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128); - + SDL_SetRenderTarget(app.renderer, app.uiBuffer); - + drawWidgetFrame(); - + drawWidgets(); - + SDL_SetRenderTarget(app.renderer, app.backBuffer); } static void drawMissionInfo(void) { int w, h, x, y, size, mid, i; - + drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128); - + SDL_SetRenderTarget(app.renderer, app.uiBuffer); - + w = 800; h = 550; x = (UI_WIDTH - w) / 2; y = (UI_HEIGHT - h) / 2; - + drawRect(x, y, w, h, 0, 0, 0, 192); drawOutlineRect(x, y, w, h, 255, 255, 255, 255); - + drawText(UI_WIDTH / 2, y + 25, 32, TA_CENTER, colors.white, selectedMission->name); - + app.textWidth = (w - 25); drawText(x + 15, y + 100, 22, TA_LEFT, colors.white, selectedMission->description); app.textWidth = 0; - + size = 65; mid = size / 2; - + y = (((UI_HEIGHT - h) / 2) + h) - 225; - + drawText(UI_WIDTH / 2, y, 24, TA_CENTER, colors.white, "Keys"); - + y += 64; - + x = ((UI_WIDTH - w) / 2) + 30; - + for (i = 0 ; i < MAX_KEY_TYPES ; i++) { drawRect(x, y, size, size, 0, 0, 0, 128); - + drawOutlineRect(x, y, size, size, 255, 255, 255, 255); - + if (game.keys[i].value.i > 0) { blitRect(atlasTexture->texture, x + mid, y + mid + 7, getCurrentFrame(keySprites[i]), 1); - + drawText(x + size - 5, y, 18, TA_RIGHT, colors.white, "%d", game.keys[i].value.i); } - + x += (size + 30); } - + SDL_SetRenderTarget(app.renderer, app.backBuffer); } static void drawPlusSettings(void) { int w, h, x, y; - + drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128); - + SDL_SetRenderTarget(app.renderer, app.uiBuffer); - + w = 800; h = 550; x = (UI_WIDTH - w) / 2; y = (UI_HEIGHT - h) / 2; - + drawRect(x, y, w, h, 0, 0, 0, 192); drawOutlineRect(x, y, w, h, 255, 255, 255, 255); - + drawText(UI_WIDTH / 2, y + 25, 32, TA_CENTER, colors.white, selectedMission->name); drawText(UI_WIDTH / 2, y + 75, 24, TA_CENTER, colors.white, app.strings[ST_MISSION_CONFIG]); - + SDL_SetRenderTarget(app.renderer, app.backBuffer); } static void unlockMission(char *id) { Tuple *t; - + for (t = game.missionStatusHead.next ; t != NULL ; t = t->next) { if (strcmp(t->key, id) == 0) @@ -573,7 +573,7 @@ static void unlockMission(char *id) if (t->value.i == MS_LOCKED || game.isComplete) { t->value.i = MS_INCOMPLETE; - + /* if the game is complete, don't reset these two */ if (game.isComplete && (strcmp(t->key, "teeka") == 0 || strcmp(t->key, "beachApproach") == 0)) { @@ -582,26 +582,26 @@ static void unlockMission(char *id) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Unlocked mission %s", id); } - + return; } } - + t = malloc(sizeof(Tuple)); memset(t, 0, sizeof(Tuple)); game.missionStatusTail->next = t; game.missionStatusTail = t; - + STRNCPY(t->key, id, MAX_NAME_LENGTH); t->value.i = MS_INCOMPLETE; - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Unlocked mission %s", id); } static int requiredMissionUnlocked(char *id) { Tuple *t; - + if (strlen(id) > 0) { for (t = game.missionStatusHead.next ; t != NULL ; t = t->next) @@ -616,14 +616,14 @@ static int requiredMissionUnlocked(char *id) { return 1; } - + return 0; } static void unlockAllMissions(void) { HubMission *mission; - + for (mission = hubMissionHead.next ; mission != NULL ; mission = mission->next) { if (mission->status == MS_LOCKED || mission->status == MS_INCOMPLETE) @@ -640,11 +640,11 @@ HubMission *getMissionAt(int x, int y) HubMission *mission; float distance, dist; double ratioX, ratioY; - + /* the original Attrition is based on 800x600, so multiply up */ ratioX = app.config.winWidth / 800.0; ratioY = app.config.winHeight / 600.0; - + rtn = NULL; distance = 32; @@ -653,7 +653,7 @@ HubMission *getMissionAt(int x, int y) if (mission->status == MS_INCOMPLETE || mission->status == MS_MISSING_HEART_CELL || mission->status == MS_PARTIAL) { dist = getDistance(x, y, mission->x * ratioX, mission->y * ratioY); - + if (dist < distance) { rtn = mission; @@ -670,21 +670,21 @@ static void startMission(void) if (!game.isComplete) { STRNCPY(game.worldId, selectedMission->id, MAX_NAME_LENGTH); - + saveGame(0); - + stopMusic(); - + destroyHub(); - + initWorld(); } else { hideAllWidgets(); - + showWidgetGroup("missionPlus"); - + doPlusSettings = 1; } } @@ -701,40 +701,40 @@ static void cancel(void) static void startMissionPlus(void) { game.plus = 0; - + if (getWidget("noDoors", "missionPlus")->value[0]) { game.plus |= PLUS_NO_DOORS; } - + if (getWidget("randomEnemies", "missionPlus")->value[0]) { game.plus |= PLUS_RANDOM; } - + if (getWidget("tougherEnemies", "missionPlus")->value[0]) { game.plus |= PLUS_STRONGER; } - + if (getWidget("defeatAllEnemies", "missionPlus")->value[0]) { game.plus |= PLUS_KILL_ALL; } - + if (getWidget("mirrorWorld", "missionPlus")->value[0]) { game.plus |= PLUS_MIRROR; } - + STRNCPY(game.worldId, selectedMission->id, MAX_NAME_LENGTH); - + saveGame(0); - + stopMusic(); - + destroyHub(); - + initWorld(); } @@ -759,9 +759,9 @@ static void trophies(void) static void quit(void) { stopMusic(); - + destroyHub(); - + initTitle(); } @@ -776,7 +776,7 @@ static void returnFromOptions(void) { app.delegate.logic = &logic; app.delegate.draw = &draw; - + returnFromTrophyStats(); } @@ -785,30 +785,30 @@ static void loadMissions(void) cJSON *root, *node; char *text; HubMission *mission; - + text = readFile("data/hub/missions.json"); root = cJSON_Parse(text); - + for (node = cJSON_GetObjectItem(root, "missions")->child ; node != NULL ; node = node->next) { mission = malloc(sizeof(HubMission)); memset(mission, 0, sizeof(HubMission)); hubMissionTail->next = mission; hubMissionTail = mission; - + STRNCPY(mission->id, cJSON_GetObjectItem(node, "id")->valuestring, MAX_NAME_LENGTH); STRNCPY(mission->name, cJSON_GetObjectItem(node, "name")->valuestring, MAX_NAME_LENGTH); STRNCPY(mission->description, _(cJSON_GetObjectItem(node, "description")->valuestring), MAX_DESCRIPTION_LENGTH); STRNCPY(mission->requires, cJSON_GetObjectItem(node, "requires")->valuestring, MAX_NAME_LENGTH); mission->status = MS_LOCKED; - + mission->x = cJSON_GetObjectItem(node, "x")->valuedouble; mission->y = cJSON_GetObjectItem(node, "y")->valuedouble; } - + cJSON_Delete(root); - + free(text); } @@ -818,7 +818,7 @@ static void awardMissionTrophies(void) HubMission *mission; beach = greenlands = underground = outpost = 1; - + save = 0; for (mission = hubMissionHead.next ; mission != NULL ; mission = mission->next) @@ -874,14 +874,14 @@ static void awardMissionTrophies(void) awardTrophy("CLEAN"); save = 1; } - + /* ignore Teeka's */ if (game.totalMissions - game.stats[STAT_MISSIONS_COMPLETE] == 1) { awardTrophy("FULLY_CLEAN"); save = 1; } - + if (save) { saveGame(0); @@ -900,7 +900,7 @@ void destroyHub(void) free(m); } - + memset(&hubMissionHead, 0, sizeof(HubMission)); hubMissionTail = &hubMissionHead; } diff --git a/src/hub/hub.h b/src/hub/hub.h index c3437ea..2d5e1cf 100644 --- a/src/hub/hub.h +++ b/src/hub/hub.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/hub/postMission.c b/src/hub/postMission.c index bb7d92d..bcf3590 100644 --- a/src/hub/postMission.c +++ b/src/hub/postMission.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -36,37 +36,37 @@ static int canContinue; void initPostMission(void) { startSectionTransition(); - + atlasTexture = getTexture("gfx/atlas/atlas.png"); background = getImageFromAtlas("gfx/radar/background.png"); - + updateMissionStatus(); - + if (world.state == WS_GAME_COMPLETE) { saveGameAndWorld(); destroyWorld(); - + initEnding(); } else if (world.state != WS_QUIT) { app.restrictTrophyAlert = 0; - + canContinue = 0; - + oNum = 0; - + missionCompleteY = UI_HEIGHT; - + playSound(SND_MISSION_COMPLETE, 0); - + app.delegate.logic = &logic; app.delegate.draw = &draw; - + saveGameAndWorld(); - + endSectionTransition(); } else @@ -78,10 +78,10 @@ void initPostMission(void) else { restoreGameState(); - + saveGame(0); } - + destroyWorld(); initHub(); @@ -91,9 +91,9 @@ void initPostMission(void) static void saveGameAndWorld(void) { char *src, *dest; - + saveGame(1); - + if (game.plus == PLUS_NONE) { saveWorld(); @@ -101,15 +101,15 @@ static void saveGameAndWorld(void) src = buildFormattedString("%s/%d/%s.json.tmp", app.saveDir, game.saveSlot, world.id); dest = buildFormattedString("%s/%d/%s.json", app.saveDir, game.saveSlot, world.id); renameFile(src, dest); - + free(src); free(dest); } - + src = buildFormattedString("%s/%d/game.json.tmp", app.saveDir, game.saveSlot); dest = buildFormattedString("%s/%d/game.json", app.saveDir, game.saveSlot, world.id); renameFile(src, dest); - + free(src); free(dest); } @@ -117,18 +117,18 @@ static void saveGameAndWorld(void) void retryMission(void) { restoreGameState(); - + saveGame(0); - + initWorld(); } void returnToHub(void) { restoreGameState(); - + saveGame(0); - + destroyWorld(); initHub(); @@ -137,7 +137,7 @@ void returnToHub(void) static void updateMissionStatus(void) { Tuple *t; - + for (t = game.missionStatusHead.next ; t != NULL ; t = t->next) { if (strcmp(t->key, world.id) == 0) @@ -146,12 +146,12 @@ static void updateMissionStatus(void) return; } } - + t = malloc(sizeof(Tuple)); memset(t, 0, sizeof(Tuple)); game.missionStatusTail->next = t; game.missionStatusTail = t; - + STRNCPY(t->key, world.id, MAX_NAME_LENGTH); t->value.i = status = getPostMissionStatus(); } @@ -159,23 +159,23 @@ static void updateMissionStatus(void) static void logic(void) { int done; - + done = (status == MS_INCOMPLETE); - + missionCompleteY = limit(missionCompleteY - 10, 50, SCREEN_HEIGHT); - + if (missionCompleteY == 50) { oNum += 0.1; } - + if (canContinue && isAcceptControl()) { done = 1; - + clearControls(); } - + if (done) { destroyWorld(); @@ -190,49 +190,49 @@ static void draw(void) SDL_Color c; char *status; int x, y, w, i; - + blitRectScaled(atlasTexture->texture, 0, 0, app.config.winWidth, app.config.winHeight, &background->rect, 0); - + SDL_SetRenderTarget(app.renderer, app.uiBuffer); - + drawText(UI_WIDTH / 2, missionCompleteY, 45, TA_CENTER, colors.white, app.strings[ST_MISSION_COMPLETE]); - + i = 0; - + if (missionCompleteY == 50) { w = 800; x = (UI_WIDTH - w) / 2; y = 150; - + for (o = world.objectiveHead.next ; o != NULL ; o = o->next) { c = o->required ? colors.red : colors.white; status = app.strings[ST_INCOMPLETE]; - + if (o->currentValue >= o->targetValue) { c = colors.green; status = app.strings[ST_COMPLETE]; } - + drawText(x + 20, y, 24, TA_LEFT, c, o->description); drawText(UI_WIDTH / 2 + 100, y, 24, TA_LEFT, c, "%d / %d", MIN(o->currentValue, o->targetValue), o->targetValue); drawText(x + w - 20, y, 24, TA_RIGHT, c, status); - + y += 55; - + if (oNum < ++i) { return; } } - + drawText(UI_WIDTH / 2, UI_HEIGHT - 80, 24, TA_CENTER, colors.white, app.strings[ST_PRESS_FIRE]); - + canContinue = 1; } - + SDL_SetRenderTarget(app.renderer, app.backBuffer); } diff --git a/src/hub/postMission.h b/src/hub/postMission.h index 997c779..484c33f 100644 --- a/src/hub/postMission.h +++ b/src/hub/postMission.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/main.c b/src/main.c index 404effd..93f792f 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -29,63 +29,63 @@ int main(int argc, char *argv[]) float remainder; memset(&app, 0, sizeof(App)); - + atexit(cleanup); srand(time(NULL)); - + initLookups(); - + init18N(argc, argv); - + initSDL(); - + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN); - + initGameSystem(); - + handleCommandLine(argc, argv); - + frames = 0; - + remainder = 0; - + nextSecond = SDL_GetTicks() + 1000; - + while (1) { then = SDL_GetTicks(); - + handleInput(); - + app.delegate.logic(); - + doTrophyAlerts(); - + prepareScene(); app.delegate.draw(); - + drawTrophyAlert(); - + presentScene(); - + capFrameRate(&then, &remainder); - + frames++; - + if (SDL_GetTicks() >= nextSecond) { dev.fps = frames; - + frames = 0; - + game.stats[STAT_TIME_PLAYED]++; - + nextSecond = SDL_GetTicks() + 1000; awardTrophies(); - + if (dev.takeScreenshots) { saveScreenshot(NULL); @@ -99,22 +99,22 @@ int main(int argc, char *argv[]) static void capFrameRate(long *then, float *remainder) { long wait; - + wait = 16 + *remainder; - + *remainder -= (int)*remainder; - + wait -= (SDL_GetTicks() - *then); - + if (wait < 0) { wait = 1; } - + SDL_Delay(wait); - + *remainder += 0.667; - + *then = SDL_GetTicks(); } @@ -124,7 +124,7 @@ static void handleCommandLine(int argc, char *argv[]) char *worldId; worldId = NULL; - + for (i = 1 ; i < argc ; i++) { if (strcmp(argv[i], "-debug") == 0) @@ -179,20 +179,20 @@ static void handleCommandLine(int argc, char *argv[]) { worldId = argv[++i]; } - + if (strcmp(argv[i], "-ending") == 0) { initEnding(); return; } - + if (strcmp(argv[i], "-credits") == 0) { initCredits(); return; } } - + if (worldId != NULL) { initWorldTest(worldId); diff --git a/src/main.h b/src/main.h index 74d2e69..b70cca7 100644 --- a/src/main.h +++ b/src/main.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/plat/unix/unixInit.c b/src/plat/unix/unixInit.c index 04e26bd..36a7b45 100644 --- a/src/plat/unix/unixInit.c +++ b/src/plat/unix/unixInit.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -21,31 +21,31 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "unixInit.h" static void mkpath(const char *path); - + void createSaveFolder(void) { char *userHome, *dir; int i; - + userHome = getenv("HOME"); - + if (!userHome) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "Unable to determine user save folder."); exit(1); } - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "User home = %s", userHome); - + for (i = 0 ; i < MAX_SAVE_SLOTS ; i++) { dir = buildFormattedString("%s/.local/share/blobwarsAttrition/%d", userHome, i); - + mkpath(dir); - + free(dir); } - + app.saveDir = buildFormattedString("%s/.local/share/blobwarsAttrition", userHome); } @@ -53,11 +53,11 @@ static void mkpath(const char *path) { char dir[MAX_FILENAME_LENGTH]; int i, rootPath; - + strcpy(dir, ""); - + rootPath = 1; - + for (i = 0 ; i < strlen(path) ; i++) { if (path[i] == '/') @@ -70,14 +70,14 @@ static void mkpath(const char *path) exit(1); } } - + rootPath = 0; } - + dir[i] = path[i]; dir[i + 1] = '\0'; } - + if (mkdir(dir, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH) != 0 && errno != EEXIST) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "Failed to create save dir '%s'.", dir); @@ -88,6 +88,6 @@ static void mkpath(const char *path) void createScreenshotFolder(void) { mkdir("/tmp/blobwarsAttrition", S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH); - + dev.screenshotFolder = "/tmp/blobwarsAttrition"; } diff --git a/src/plat/unix/unixInit.h b/src/plat/unix/unixInit.h index a30b993..6a8bae7 100644 --- a/src/plat/unix/unixInit.h +++ b/src/plat/unix/unixInit.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/plat/win32/win32Init.c b/src/plat/win32/win32Init.c index 32a19b7..70cee4f 100644 --- a/src/plat/win32/win32Init.c +++ b/src/plat/win32/win32Init.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -26,26 +26,26 @@ void createSaveFolder(void) { char *userHome, *dir; int i; - + userHome = getenv("USERPROFILE"); - + if (!userHome) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "Unable to determine user save folder."); exit(1); } - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "User home = %s", userHome); - + for (i = 0 ; i < MAX_SAVE_SLOTS ; i++) { dir = buildFormattedString("%s\\blobwarsAttrition\\%d", userHome, i); - + mkpath(dir); - + free(dir); } - + app.saveDir = buildFormattedString("%s\\blobwarsAttrition", userHome); } @@ -53,11 +53,11 @@ void mkpath(const char *path) { char dir[MAX_FILENAME_LENGTH]; int i, rootPath; - + strcpy(dir, ""); - + rootPath = 1; - + for (i = 0 ; i < strlen(path) ; i++) { if (path[i] == '\\' || i == strlen(path) - 1) @@ -70,14 +70,14 @@ void mkpath(const char *path) exit(1); } } - + rootPath = 0; } - + dir[i] = path[i]; dir[i + 1] = '\0'; } - + if (mkdir(dir) != 0 && errno != EEXIST) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "Failed to create save dir '%s'.", dir); diff --git a/src/plat/win32/win32Init.h b/src/plat/win32/win32Init.h index 464a5db..2cf92a7 100644 --- a/src/plat/win32/win32Init.h +++ b/src/plat/win32/win32Init.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/structs.h b/src/structs.h index d958778..7335fb0 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/system/atlas.c b/src/system/atlas.c index c71bd66..f079f5e 100644 --- a/src/system/atlas.c +++ b/src/system/atlas.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -37,7 +37,7 @@ Atlas *getImageFromAtlas(char *filename) unsigned long i; i = hashcode(filename) % NUM_ATLAS_BUCKETS; - + for (a = atlases[i].next ; a != NULL ; a = a->next) { if (strcmp(a->filename, filename) == 0) @@ -45,12 +45,12 @@ Atlas *getImageFromAtlas(char *filename) return a; } } - + if (!strstr(filename, "/tiles/")) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "No such atlas image '%s'", filename); } - + return NULL; } @@ -61,11 +61,11 @@ static void loadAtlasData(void) cJSON *root, *node; char *text, *filename; unsigned long i; - + text = readFile("data/atlas/atlas.json"); root = cJSON_Parse(text); - + for (node = root->child ; node != NULL ; node = node->next) { filename = cJSON_GetObjectItem(node, "filename")->valuestring; @@ -83,19 +83,19 @@ static void loadAtlasData(void) { a = a->next; } - + atlas = malloc(sizeof(Atlas)); memset(atlas, 0, sizeof(Atlas)); a->next = atlas; - + STRNCPY(atlas->filename, filename, MAX_FILENAME_LENGTH); atlas->rect.x = x; atlas->rect.y = y; atlas->rect.w = w; atlas->rect.h = h; } - + cJSON_Delete(root); - + free(text); } diff --git a/src/system/atlas.h b/src/system/atlas.h index 1a28b99..5621b4a 100644 --- a/src/system/atlas.h +++ b/src/system/atlas.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/system/controls.h b/src/system/controls.h index 321c2dc..4bcfabe 100644 --- a/src/system/controls.h +++ b/src/system/controls.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/system/draw.c b/src/system/draw.c index 2edbddc..24bad67 100644 --- a/src/system/draw.c +++ b/src/system/draw.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -28,13 +28,13 @@ void initBackground(void) { backgroundPoint[0].x = -app.config.winWidth / 2; backgroundPoint[0].y = -app.config.winHeight / 2; - + backgroundPoint[1].x = app.config.winWidth / 2; backgroundPoint[1].y = -app.config.winHeight / 2; - + backgroundPoint[2].x = -app.config.winWidth / 2; backgroundPoint[2].y = app.config.winHeight / 2; - + backgroundPoint[3].x = app.config.winWidth / 2; backgroundPoint[3].y = app.config.winHeight / 2; } @@ -52,9 +52,9 @@ void initGraphics(void) initColor(&colors.black, 0, 0, 0); initColor(&colors.lightGrey, 192, 192, 192); initColor(&colors.darkGrey, 128, 128, 128); - + app.backBuffer = SDL_CreateTexture(app.renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, app.config.winWidth, app.config.winHeight); - + app.uiBuffer = SDL_CreateTexture(app.renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, UI_WIDTH, UI_HEIGHT); SDL_SetTextureBlendMode(app.uiBuffer, SDL_BLENDMODE_BLEND); @@ -67,7 +67,7 @@ void prepareScene(void) SDL_SetRenderTarget(app.renderer, app.uiBuffer); SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0); SDL_RenderClear(app.renderer); - + SDL_SetRenderTarget(app.renderer, app.backBuffer); SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 255); SDL_RenderClear(app.renderer); @@ -76,22 +76,22 @@ void prepareScene(void) void presentScene(void) { SDL_Rect uiDest; - + uiDest.w = UI_WIDTH; uiDest.h = UI_HEIGHT; uiDest.x = (app.config.winWidth / 2) - (UI_WIDTH / 2); uiDest.y = (app.config.winHeight / 2) - (UI_HEIGHT / 2); - + if (dev.debug) { drawText(5, app.config.winHeight - 25, 14, TA_LEFT, colors.white, "DEBUG MODE"); - + if (dev.showFPS) { drawText(app.config.winWidth - 5, app.config.winHeight - 25, 14, TA_RIGHT, colors.white, "FPS: %d", dev.fps); } } - + SDL_SetRenderTarget(app.renderer, NULL); SDL_RenderCopy(app.renderer, app.backBuffer, NULL, NULL); SDL_RenderCopy(app.renderer, app.uiBuffer, NULL, &uiDest); @@ -108,7 +108,7 @@ void clearScreen(void) void blit(SDL_Texture *texture, int x, int y, int center) { SDL_Rect dstRect; - + dstRect.x = x; dstRect.y = y; SDL_QueryTexture(texture, NULL, NULL, &dstRect.w, &dstRect.h); @@ -125,7 +125,7 @@ void blit(SDL_Texture *texture, int x, int y, int center) void blitRect(SDL_Texture *texture, int x, int y, SDL_Rect *srcRect, int center) { SDL_Rect dstRect; - + dstRect.x = x; dstRect.y = y; dstRect.w = srcRect->w; @@ -143,12 +143,12 @@ void blitRect(SDL_Texture *texture, int x, int y, SDL_Rect *srcRect, int center) void blitRectRotated(SDL_Texture *texture, int x, int y, SDL_Rect *srcRect, float angle) { SDL_Rect dstRect; - + dstRect.x = x; dstRect.y = y; dstRect.w = srcRect->w; dstRect.h = srcRect->h; - + dstRect.x -= (srcRect->w / 2); dstRect.y -= (srcRect->h / 2); @@ -158,12 +158,12 @@ void blitRectRotated(SDL_Texture *texture, int x, int y, SDL_Rect *srcRect, floa void blitScaled(SDL_Texture *texture, int x, int y, int w, int h, int center) { SDL_Rect dstRect; - + dstRect.x = x; dstRect.y = y; dstRect.w = w; dstRect.h = h; - + if (center) { dstRect.x -= (dstRect.w / 2); @@ -176,7 +176,7 @@ void blitScaled(SDL_Texture *texture, int x, int y, int w, int h, int center) void blitRectScaled(SDL_Texture *texture, int x, int y, int w, int h, SDL_Rect *srcRect, int center) { SDL_Rect dstRect; - + dstRect.x = x; dstRect.y = y; dstRect.w = w; @@ -204,7 +204,7 @@ void drawRect(int x, int y, int w, int h, int r, int g, int b, int a) rect.y = y; rect.w = w; rect.h = h; - + SDL_SetRenderDrawBlendMode(app.renderer, a < 255 ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE); SDL_SetRenderDrawColor(app.renderer, r, g, b, a); SDL_RenderFillRect(app.renderer, &rect); @@ -217,7 +217,7 @@ void drawOutlineRect(int x, int y, int w, int h, int r, int g, int b, int a) rect.y = y; rect.w = w; rect.h = h; - + SDL_SetRenderDrawBlendMode(app.renderer, a < 255 ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE); SDL_SetRenderDrawColor(app.renderer, r, g, b, a); SDL_RenderDrawRect(app.renderer, &rect); @@ -226,27 +226,27 @@ void drawOutlineRect(int x, int y, int w, int h, int r, int g, int b, int a) void scrollBackground(float x, float y) { int i; - + for (i = 0 ; i < 4 ; i++) { backgroundPoint[i].x += x; backgroundPoint[i].y += y; - + if (backgroundPoint[i].x < 0) { backgroundPoint[i].x += (app.config.winWidth * 2); } - + if (backgroundPoint[i].x >= app.config.winWidth) { backgroundPoint[i].x -= (app.config.winWidth * 2); } - + if (backgroundPoint[i].y < 0) { backgroundPoint[i].y += (app.config.winHeight * 2); } - + if (backgroundPoint[i].y >= app.config.winHeight) { backgroundPoint[i].y -= (app.config.winHeight * 2); @@ -258,7 +258,7 @@ void drawBackground(SDL_Texture *texture) { int i; SDL_Rect dstRect; - + for (i = 0 ; i < 4 ; i++) { dstRect.x = backgroundPoint[i].x; @@ -283,7 +283,7 @@ void saveScreenshot(char *name) { char *filename; SDL_Surface *screenshot; - + if (name != NULL) { filename = buildFormattedString("%s/%d/%s.png", app.saveDir, game.saveSlot, name); @@ -292,11 +292,11 @@ void saveScreenshot(char *name) { filename = buildFormattedString("%s/%d.png", dev.screenshotFolder, SDL_GetTicks()); } - + screenshot = SDL_CreateRGBSurface(0, SCREEN_WIDTH, SCREEN_HEIGHT, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); SDL_RenderReadPixels(app.renderer, NULL, SDL_PIXELFORMAT_ARGB8888, screenshot->pixels, screenshot->pitch); SDL_SavePNG(screenshot, filename); SDL_FreeSurface(screenshot); - + free(filename); } diff --git a/src/system/draw.h b/src/system/draw.h index 042e807..969c01d 100644 --- a/src/system/draw.h +++ b/src/system/draw.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/system/init.c b/src/system/init.c index 0795a9a..a340848 100644 --- a/src/system/init.c +++ b/src/system/init.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -53,16 +53,16 @@ void init18N(int argc, char *argv[]) void initSDL(void) { int rendererFlags, windowFlags; - + /* done in src/plat/ */ createSaveFolder(); loadConfig(); rendererFlags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC; - + windowFlags = 0; - + if (app.config.fullscreen) { windowFlags |= SDL_WINDOW_FULLSCREEN; @@ -100,12 +100,12 @@ void initSDL(void) } initJoypad(); - + app.uiOffset.x = (app.config.winWidth / 2) - (UI_WIDTH / 2); app.uiOffset.y = (app.config.winHeight / 2) - (UI_HEIGHT / 2); SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "UI offset: %d,%d\n", app.uiOffset.x, app.uiOffset.y); - + SDL_ShowCursor(SDL_DISABLE); } @@ -120,7 +120,7 @@ static void initJoypad(void) for (i = 0 ; i < n ; i++) { app.joypad = SDL_JoystickOpen(i); - + if (app.joypad) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Using joystick '%s'", SDL_JoystickNameForIndex(i)); @@ -198,7 +198,7 @@ static void initDefaultConfig(void) app.config.winWidth = SCREEN_WIDTH; app.config.winHeight = SCREEN_HEIGHT; - + app.config.inventory = 1; app.config.blood = 1; app.config.trophyAlert = 1; @@ -221,7 +221,7 @@ static void initDefaultConfig(void) { app.config.joypadControls[i] = -1; } - + app.config.joypadControls[CONTROL_JUMP] = 1; app.config.joypadControls[CONTROL_FIRE] = 3; app.config.joypadControls[CONTROL_JETPACK] = 2; @@ -236,7 +236,7 @@ static void loadConfig(void) char *text, *filename; initDefaultConfig(); - + filename = buildFormattedString("%s/%s", app.saveDir, CONFIG_FILENAME); if (fileExists(filename)) @@ -251,7 +251,7 @@ static void loadConfig(void) app.config.musicVolume = cJSON_GetObjectItem(root, "musicVolume")->valueint; app.config.soundVolume = cJSON_GetObjectItem(root, "soundVolume")->valueint; - + app.config.inventory = cJSON_GetObjectItem(root, "inventory")->valueint; app.config.blood = cJSON_GetObjectItem(root, "blood")->valueint; app.config.trophyAlert = cJSON_GetObjectItem(root, "trophyAlert")->valueint; @@ -283,11 +283,11 @@ static void loadConfig(void) cJSON_Delete(root); free(text); } - + /* don't go higher than 8K or lower than 1280 x 720 */ app.config.winWidth = MIN(MAX(app.config.winWidth, 1280), 7680); app.config.winHeight = MIN(MAX(app.config.winHeight, 720), 4320); - + free(filename); } @@ -302,14 +302,14 @@ void saveConfig(void) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Saving config ..."); root = cJSON_CreateObject(); - + cJSON_AddNumberToObject(root, "fullscreen", app.config.fullscreen); cJSON_AddNumberToObject(root, "winWidth", app.config.winWidth); cJSON_AddNumberToObject(root, "winHeight", app.config.winHeight); - + cJSON_AddNumberToObject(root, "musicVolume", app.config.musicVolume); cJSON_AddNumberToObject(root, "soundVolume", app.config.soundVolume); - + cJSON_AddNumberToObject(root, "blood", app.config.blood); cJSON_AddNumberToObject(root, "inventory", app.config.inventory); cJSON_AddNumberToObject(root, "trophyAlert", app.config.trophyAlert); @@ -341,32 +341,32 @@ void saveConfig(void) cJSON_Delete(root); free(out); - + free(filename); } void cleanup(void) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Cleaning up ..."); - + destroyLookups(); - + destroyTextures(); - + destroyGame(); if (app.joypad != NULL) { SDL_JoystickClose(app.joypad); } - + SDL_DestroyRenderer(app.renderer); - + SDL_DestroyWindow(app.window); - + TTF_Quit(); - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Done."); - + SDL_Quit(); } diff --git a/src/system/init.h b/src/system/init.h index d32a4ec..95a7b25 100644 --- a/src/system/init.h +++ b/src/system/init.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" +#include "../common.h" #include "../json/cJSON.h" #include "SDL2/SDL_image.h" diff --git a/src/system/input.c b/src/system/input.c index 327a16a..47b5555 100644 --- a/src/system/input.c +++ b/src/system/input.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -109,7 +109,7 @@ static void doJoyAxis(SDL_JoyAxisEvent *event) void clearInput(void) { SDL_Event event; - + memset(app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS); memset(&app.mouse, 0, sizeof(Mouse)); memset(&app.joypadButton, 0, sizeof(int) * SDL_CONTROLLER_BUTTON_MAX); @@ -122,10 +122,10 @@ void clearInput(void) void handleInput(void) { SDL_Event event; - + app.mouse.dx = 0; app.mouse.dy = 0; - + while (SDL_PollEvent(&event)) { switch (event.type) @@ -133,11 +133,11 @@ void handleInput(void) case SDL_MOUSEMOTION: doMouseMotion(&event.motion); break; - + case SDL_MOUSEWHEEL: doMouseWheel(&event.wheel); break; - + case SDL_MOUSEBUTTONDOWN: doMouseDown(&event.button); break; @@ -145,11 +145,11 @@ void handleInput(void) case SDL_MOUSEBUTTONUP: doMouseUp(&event.button); break; - + case SDL_KEYDOWN: doKeyDown(&event.key); break; - + case SDL_KEYUP: doKeyUp(&event.key); break; @@ -161,16 +161,16 @@ void handleInput(void) case SDL_JOYBUTTONUP: doButtonUp(&event.jbutton); break; - + case SDL_JOYAXISMOTION: doJoyAxis(&event.jaxis); break; - + case SDL_QUIT: exit(0); break; } } - + SDL_GetMouseState(&app.mouse.x, &app.mouse.y); } diff --git a/src/system/input.h b/src/system/input.h index decc46b..aa50882 100644 --- a/src/system/input.h +++ b/src/system/input.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/system/io.c b/src/system/io.c index 881b607..556f043 100644 --- a/src/system/io.c +++ b/src/system/io.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -32,9 +32,9 @@ int fileExists(const char *filename) long getFileModTime(const char *filename) { struct stat buffer; - + stat(filename, &buffer); - + return buffer.st_mtime; } @@ -49,7 +49,7 @@ const char *getFileLocation(const char *filename) } sprintf(path, DATA_DIR"/%s", filename); - + if (!fileExists(path)) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_CRITICAL, "No such file '%s'", path); @@ -76,7 +76,7 @@ char *readFile(const char *filename) fread(buffer, 1, length, file); fclose(file); - + buffer[length] = '\0'; } @@ -89,7 +89,7 @@ char *readCompressedFile(const char *filename) uint32_t l1, l2; unsigned long length, cLength; FILE *file = fopen(getFileLocation(filename), "rb"); - + buffer = 0; cBuffer = 0; @@ -97,29 +97,29 @@ char *readCompressedFile(const char *filename) { fread(&l1, sizeof(uint32_t), 1, file); fread(&l2, sizeof(uint32_t), 1, file); - + l1 = SDL_SwapLE32(l1); l2 = SDL_SwapLE32(l2); - + length = l1; cLength = l2; - + buffer = malloc(length + 1); memset(buffer, 0, length + 1); - + cBuffer = malloc(cLength + 1); memset(cBuffer, 0, cLength + 1); - + fread(cBuffer, 1, cLength, file); - + uncompress(buffer, &length, cBuffer, cLength); fclose(file); - + buffer[length] = '\0'; - + free(cBuffer); - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Decompressed '%s' %ld -> %ld", filename, cLength, length); } diff --git a/src/system/io.h b/src/system/io.h index b4a7fb8..ef8319b 100644 --- a/src/system/io.h +++ b/src/system/io.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/system/lookup.c b/src/system/lookup.c index 712bce3..8b8c375 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -23,25 +23,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static Lookup head; static Lookup *tail; -static void addLookup(const char *name, long value); +static void addLookup(const char *name, long value); void initLookups(void) { memset(&head, 0, sizeof(Lookup)); tail = &head; - + addLookup("FACING_LEFT", FACING_LEFT); addLookup("FACING_RIGHT", FACING_RIGHT); - + addLookup("LIFT_GOTO_FINISH", LIFT_GOTO_FINISH); addLookup("LIFT_GOTO_START", LIFT_GOTO_START); - + addLookup("DOOR_OPEN", DOOR_OPEN); addLookup("DOOR_CLOSED", DOOR_CLOSED); - + addLookup("WPN_PLASMA", WPN_PLASMA); addLookup("WPN_SPREAD", WPN_SPREAD); - + addLookup("CONTROL_LEFT", CONTROL_LEFT); addLookup("CONTROL_RIGHT", CONTROL_RIGHT); addLookup("CONTROL_UP", CONTROL_UP); @@ -51,23 +51,23 @@ void initLookups(void) addLookup("CONTROL_JETPACK", CONTROL_JETPACK); addLookup("CONTROL_PAUSE", CONTROL_PAUSE); addLookup("CONTROL_MAP", CONTROL_MAP); - + addLookup("WT_BUTTON", WT_BUTTON); addLookup("WT_SPINNER", WT_SPINNER); addLookup("WT_SLIDER", WT_SLIDER); addLookup("WT_INPUT", WT_INPUT); - + addLookup("MS_LOCKED", MS_LOCKED); addLookup("MS_INCOMPLETE", MS_INCOMPLETE); addLookup("MS_PARTIAL", MS_PARTIAL); addLookup("MS_MISSING_HEART_CELL", MS_MISSING_HEART_CELL); addLookup("MS_COMPLETE", MS_COMPLETE); - + addLookup("TROPHY_BRONZE", TROPHY_BRONZE); addLookup("TROPHY_SILVER", TROPHY_SILVER); addLookup("TROPHY_GOLD", TROPHY_GOLD); addLookup("TROPHY_PLATINUM", TROPHY_PLATINUM); - + addLookup("STAT_MISSIONS_COMPLETE", STAT_MISSIONS_COMPLETE); addLookup("STAT_KEYS_FOUND", STAT_KEYS_FOUND); addLookup("STAT_CELLS_FOUND", STAT_CELLS_FOUND); diff --git a/src/system/lookup.h b/src/system/lookup.h index 8ad0dc9..9e69b70 100644 --- a/src/system/lookup.h +++ b/src/system/lookup.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/system/sound.c b/src/system/sound.c index 004ba7d..70ea0d3 100644 --- a/src/system/sound.c +++ b/src/system/sound.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -87,7 +87,7 @@ void playBattleSound(int snd, int channel, int x, int y) if (distance <= MAX_BATTLE_SOUND_DISTANCE) { channel = Mix_PlayChannel(channel, sounds[snd], 0); - + if (channel != -1) { vol = 255; @@ -97,7 +97,7 @@ void playBattleSound(int snd, int channel, int x, int y) if (distance >= MIN_BATTLE_SOUND_DISTANCE) { bearing = 360 - getAngle(x, y, world.bob->x, world.bob->y); - + Mix_SetPosition(channel, (Sint16)bearing, (Uint8)vol); } else @@ -123,7 +123,7 @@ static void loadSounds(void) sounds[SND_MENU_BACK] = loadSound("sound/50557__broumbroum__sf3-sfx-menu-back.ogg"); sounds[SND_MENU_SELECT] = loadSound("sound/50561__broumbroum__sf3-sfx-menu-select.ogg"); sounds[SND_MENU_NAV] = loadSound("sound/146721__fins__menu-click.ogg"); - + sounds[SND_PISTOL] = loadSound("sound/Gun_44magnum-freesoundeffects.ogg"); sounds[SND_MACHINE_GUN] = loadSound("sound/67020__ls__submachinegun2.ogg"); sounds[SND_PLASMA] = loadSound("sound/93017__cosmicd__60.ogg"); @@ -165,7 +165,7 @@ static void loadSounds(void) sounds[SND_ITEM_PAD] = loadSound("sound/319996__kenrt__ratchet.ogg"); sounds[SND_POWER_POOL] = loadSound("sound/235737__copyc4t__tf-power-tools.ogg"); sounds[SND_POP] = loadSound("sound/83237__mlestn1__pop.ogg"); - + sounds[SND_MISSION_COMPLETE] = loadSound("sound/113989__kastenfrosch__gewonnen.ogg"); sounds[SND_TROPHY] = loadSound("sound/278142__ricemaster__effect-notify.ogg"); } diff --git a/src/system/sound.h b/src/system/sound.h index a705fcb..959f4d4 100644 --- a/src/system/sound.h +++ b/src/system/sound.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/system/sprites.c b/src/system/sprites.c index d6f5d77..5effe78 100644 --- a/src/system/sprites.c +++ b/src/system/sprites.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -32,14 +32,14 @@ void initSprites(void) { memset(&spriteHead, 0, sizeof(Sprite)); spriteTail = &spriteHead; - + loadGameSprites(); } Sprite *getSprite(char *name) { Sprite *s; - + for (s = spriteHead.next ; s != NULL ; s = s->next) { if (strcmp(s->name, name) == 0) @@ -47,7 +47,7 @@ Sprite *getSprite(char *name) return s; } } - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "No such sprite '%s'", name); exit(1); @@ -57,7 +57,7 @@ Sprite *getSprite(char *name) void animateSprites(void) { Sprite *s; - + for (s = spriteHead.next ; s != NULL ; s = s->next) { animateSprite(s); @@ -112,14 +112,14 @@ static void loadSpriteList(char *filename) text = readFile(filename); root = cJSON_Parse(text); - + for (node = root->child ; node != NULL ; node = node->next) { loadSprite(node); } - + cJSON_Delete(root); - + free(text); } @@ -129,41 +129,41 @@ void loadSprite(cJSON *root) cJSON *frame; char *filename; int i; - + s = malloc(sizeof(Sprite)); memset(s, 0, sizeof(Sprite)); spriteTail->next = s; spriteTail = s; - + STRNCPY(s->name, cJSON_GetObjectItem(root, "name")->valuestring, MAX_NAME_LENGTH); - + for (frame = cJSON_GetObjectItem(root, "frame")->child ; frame != NULL ; frame = frame->next) { s->numFrames++; } - + s->times = malloc(sizeof(int) * s->numFrames); s->filenames = malloc(sizeof(char*) * s->numFrames); s->frames = malloc(sizeof(Atlas*) * s->numFrames); - + i = 0; - + for (frame = cJSON_GetObjectItem(root, "frame")->child ; frame != NULL ; frame = frame->next) { s->times[i] = cJSON_GetObjectItem(frame, "time")->valueint; - + if (cJSON_GetObjectItem(frame, "content") != NULL) { filename = cJSON_GetObjectItem(frame, "content")->valuestring; s->filenames[i] = malloc(strlen(filename) + 1); STRNCPY(s->filenames[i], filename, strlen(filename)); - + s->frames[i] = getImageFromAtlas(filename); } - + i++; } - + s->w = s->frames[0]->rect.w; s->h = s->frames[0]->rect.h; } diff --git a/src/system/sprites.h b/src/system/sprites.h index 396d0e7..2a37324 100644 --- a/src/system/sprites.h +++ b/src/system/sprites.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/system/strings.c b/src/system/strings.c index ba78037..4d93e96 100644 --- a/src/system/strings.c +++ b/src/system/strings.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -27,18 +27,18 @@ void initStrings(void) app.strings[ST_INCOMPLETE] = _("Incomplete"); app.strings[ST_COMPLETE] = _("Complete"); app.strings[ST_PRESS_FIRE] = _("Press Fire to Continue"); - + app.strings[ST_OPTIONS] = _("Options"); app.strings[ST_CONTROLS] = _("Controls"); app.strings[ST_TROPHIES] = _("Trophies"); app.strings[ST_PAGE] = _("Page %d / %d"); app.strings[ST_HIDDEN] = _("Hidden"); - + app.strings[ST_WEAPON] = _("Weapon: %s"); - + app.strings[ST_CELL] = _("Found a battery cell - Max power increased!"); app.strings[ST_HEART] = _("Found a heart - Max health increased!"); - + app.strings[ST_TELEPORTER] = _("Teleporter activated ..."); app.strings[ST_LASERS] = _("Lasers disabled ..."); app.strings[ST_POWER_POINT] = _("Not enough power (%d units required)"); @@ -46,7 +46,7 @@ void initStrings(void) app.strings[ST_EXIT] = _("Can't exit yet - required objectives not met"); app.strings[ST_LOCKED] = _("Door is locked"); app.strings[ST_OPENED] = _("Door opened ..."); - + app.strings[ST_GOT_GRENADES] = _("Got some Grenades"); app.strings[ST_PICKED_UP] = _("Picked up a %s"); app.strings[ST_REMOVED] = _("%s removed"); @@ -54,39 +54,39 @@ void initStrings(void) app.strings[ST_CANNOT_CARRY_KEYS] = _("Can't carry any more keys"); app.strings[ST_CANNOT_CARRY_ITEMS] = _("Can't carry any more items"); app.strings[ST_RESCUED] = _("Rescued %s"); - + app.strings[ST_JETPACK_POWER] = _("Not enough power for jetpack"); app.strings[ST_AQUALUNG_POWER] = _("Not enough power for aqualung"); - + app.strings[ST_QUIT_HUB] = _("Quit and return to hub?"); app.strings[ST_QUIT_TUTORIAL] = _("As this is a tutorial mission, you can skip it and move onto the main game."); app.strings[ST_QUIT_SAVE] = _("Your progress on this mission will be saved."); app.strings[ST_QUIT_FREE_PLAY] = _("Your progress on this mission will not be saved, but you will keep any keys, Hearts, and Cells that you have collected."); app.strings[ST_QUIT_LOSE] = _("Warning: if you quit now, you will lose all progress on this level."); - + app.strings[ST_MIAS] = _("MIAs"); app.strings[ST_ITEMS] = _("Items"); app.strings[ST_TARGETS] = _("Targets"); - + app.strings[ST_OBJECTIVE_COMPLETE] = _("%s - Objective Complete!"); - + app.strings[ST_CHERRY_BUNCH] = _("bunch of cherries"); app.strings[ST_CHERRY_PAIR] = _("pair of cherries"); app.strings[ST_CHERRY_SMALL] = _("small cherry"); - + app.strings[ST_BATTERY_FULL] = _("full battery"); app.strings[ST_BATTERY] = _("battery"); app.strings[ST_USED_BATTERY] = _("used battery"); app.strings[ST_WEAK_BATTERY] = _("weak battery"); - + app.strings[ST_CHOOSE_SAVE] = _("Choose a save slot to use ..."); app.strings[ST_LOAD] = _("Choose a save game to load ..."); app.strings[ST_OVERWRITE_1] = _("Are you sure you want to overwrite this game?"); app.strings[ST_OVERWRITE_2] = _("All progress will be lost!"); - + app.strings[ST_FREEPLAY] = _("As the game is now complete, free play for this mission has been unlocked. You may replay it as often as you wish. Hearts and Cells will be randomly available. You may also configure various aspects of the mission on the next screen."); app.strings[ST_HEART_CELL] = _("All objectives for this misson have been completed. However, there is a Cell or a Heart left to find. See if you can locate it."); - + app.strings[ST_HUB_MISSIONS] = _("Missions: %d / %d"); app.strings[ST_HUB_MIAS] = _("MIAs: %d / %d"); app.strings[ST_HUB_TARGETS] = _("Targets: %d / %d"); @@ -94,7 +94,7 @@ void initStrings(void) app.strings[ST_HUB_HEARTS] = _("Hearts: %d / %d"); app.strings[ST_HUB_CELLS] = _("Cells: %d / %d"); app.strings[ST_MISSION_CONFIG] = _("Mission configuration"); - + app.strings[ST_CORRUPT_SAVE] = _("! Corrupt data"); app.strings[ST_EMPTY_SAVE] = _("- empty -"); } diff --git a/src/system/strings.h b/src/system/strings.h index 2ed81bd..39fb783 100644 --- a/src/system/strings.h +++ b/src/system/strings.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/system/text.c b/src/system/text.c index 1757e7e..dc220d1 100644 --- a/src/system/text.c +++ b/src/system/text.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -40,9 +40,9 @@ void initFonts(void) { memset(&fontHead, 0, sizeof(Font)); fontTail = &fontHead; - + initFont("roboto", getFileLocation("gfx/fonts/Roboto-Medium.ttf")); - + useFont("roboto"); } @@ -56,59 +56,59 @@ static void initFont(char *name, char *filename) Glyph *g; int i; SDL_Color white = {255, 255, 255, 255}; - + f = malloc(sizeof(Font)); memset(f, 0, sizeof(Font)); - + font = TTF_OpenFont(filename, FONT_SIZE); - + initChars(f); - + surface = SDL_CreateRGBSurface(0, FONT_TEXTURE_SIZE, FONT_TEXTURE_SIZE, 32, 0, 0, 0, 0xff); - + SDL_SetColorKey(surface, SDL_TRUE, SDL_MapRGBA(surface->format, 0, 0, 0, 0)); - + dest.x = dest.y = 0; - + for (i = 0 ; i < NUM_GLYPH_BUCKETS ; i++) { for (g = f->glyphHead[i].next ; g != NULL ; g = g->next) { text = TTF_RenderUTF8_Blended(font, g->character, white); - + TTF_SizeText(font, g->character, &dest.w, &dest.h); - + if (dest.x + dest.w >= FONT_TEXTURE_SIZE) { dest.x = 0; - + dest.y += dest.h + 1; - + if (dest.y + dest.h >= FONT_TEXTURE_SIZE) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_CRITICAL, "Out of glyph space in %dx%d font atlas texture map.", FONT_TEXTURE_SIZE, FONT_TEXTURE_SIZE); exit(1); } } - + SDL_BlitSurface(text, NULL, surface, &dest); - + g->rect = dest; - + SDL_FreeSurface(text); - + dest.x += dest.w; } } - + TTF_CloseFont(font); - + texture = toTexture(surface, 1); - + f->texture = texture; - + strcpy(f->name, name); - + fontTail->next = f; fontTail = f; } @@ -118,17 +118,17 @@ static void initChars(Font *f) char *characters, *character; Glyph *g, *glyphTail; int i, bucket; - + characters = readFile("data/locale/characters.dat"); - + i = 0; - + character = nextCharacter(characters, &i); - + while (character) { bucket = hashcode(character) % NUM_GLYPH_BUCKETS; - + glyphTail = &f->glyphHead[bucket]; /* horrible bit to look for the tail */ @@ -136,24 +136,24 @@ static void initChars(Font *f) { glyphTail = glyphTail->next; } - + g = malloc(sizeof(Glyph)); memset(g, 0, sizeof(Glyph)); glyphTail->next = g; glyphTail = g; - + STRNCPY(g->character, character, MAX_NAME_LENGTH); - + character = nextCharacter(characters, &i); } - + free(characters); } void drawText(int x, int y, int size, int align, SDL_Color color, const char *format, ...) { va_list args; - + if (activeFont) { memset(&drawTextBuffer, '\0', sizeof(drawTextBuffer)); @@ -161,31 +161,31 @@ void drawText(int x, int y, int size, int align, SDL_Color color, const char *fo va_start(args, format); vsprintf(drawTextBuffer, format, args); va_end(args); - + if (app.textWidth == 0) { SDL_SetTextureColorMod(activeFont->texture, 0, 0, 0); SDL_SetTextureAlphaMod(activeFont->texture, 255); - + drawTextLine(x + 2, y + 2, size, align, drawTextBuffer); drawTextLine(x + 1, y + 1, size, align, drawTextBuffer); - + SDL_SetTextureColorMod(activeFont->texture, color.r, color.g, color.b); SDL_SetTextureAlphaMod(activeFont->texture, color.a); - + drawTextLine(x, y, size, align, drawTextBuffer); } else { SDL_SetTextureColorMod(activeFont->texture, 0, 0, 0); SDL_SetTextureAlphaMod(activeFont->texture, 255); - + drawTextLines(x + 2, y + 2, size, align); drawTextLines(x + 1, y + 1, size, align); - + SDL_SetTextureColorMod(activeFont->texture, color.r, color.g, color.b); SDL_SetTextureAlphaMod(activeFont->texture, color.a); - + drawTextLines(x, y, size, align); } } @@ -195,43 +195,43 @@ static void drawTextLines(int x, int y, int size, int align) { char line[MAX_LINE_LENGTH], token[MAX_WORD_LENGTH]; int i, n, w, h, currentWidth, len; - + memset(&line, '\0', sizeof(line)); memset(&token, '\0', sizeof(token)); - + len = strlen(drawTextBuffer); - + n = currentWidth = 0; - + for (i = 0 ; i < len ; i++) { token[n++] = drawTextBuffer[i]; - + if (drawTextBuffer[i] == ' ' || i == len - 1) { calcTextDimensions(token, size, &w, &h); - + if (currentWidth + w > app.textWidth) { drawTextLine(x, y, size, align, line); - + currentWidth = 0; - + y += h; - + memset(&line, '\0', sizeof(line)); } - + strcat(line, token); - + n = 0; - + memset(&token, '\0', sizeof(token)); - + currentWidth += w; } } - + drawTextLine(x, y, size, align, line); } @@ -239,17 +239,17 @@ static void drawTextLine(int x, int y, int size, int align, const char *line) { int i, startX, n, w, h; char word[MAX_WORD_LENGTH]; - + scale = size / (FONT_SIZE * 1.0f); - + startX = x; - + memset(word, 0, MAX_WORD_LENGTH); - + n = 0; - + calcTextDimensions(line, size, &w, &h); - + if (align == TA_RIGHT) { x -= w; @@ -258,21 +258,21 @@ static void drawTextLine(int x, int y, int size, int align, const char *line) { x -= (w / 2); } - + for (i = 0 ; i < strlen(line) ; i++) { word[n++] = line[i]; - + if (line[i] == ' ') { drawWord(word, &x, &y, startX); - + memset(word, 0, MAX_WORD_LENGTH); - + n = 0; } } - + drawWord(word, &x, &y, startX); } @@ -282,24 +282,24 @@ static void drawWord(char *word, int *x, int *y, int startX) char *character; SDL_Rect dest; Glyph *g; - + i = 0; - + character = nextCharacter(word, &i); - + while (character) { g = findGlyph(character); - + dest.x = *x; dest.y = *y; dest.w = g->rect.w * scale; dest.h = g->rect.h * scale; - + SDL_RenderCopy(app.renderer, activeFont->texture, &g->rect, &dest); - + *x += g->rect.w * scale; - + character = nextCharacter(word, &i); } } @@ -308,9 +308,9 @@ static Glyph *findGlyph(char *c) { Glyph *g; int bucket; - + bucket = hashcode(c) % NUM_GLYPH_BUCKETS; - + for (g = activeFont->glyphHead[bucket].next ; g != NULL ; g = g->next) { if (strcmp(g->character, c) == 0) @@ -318,17 +318,17 @@ static Glyph *findGlyph(char *c) return g; } } - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_CRITICAL, "Couldn't find glyph for '%s'", c); exit(1); - + return NULL; } void useFont(char *name) { Font *f; - + for (f = fontHead.next ; f != NULL ; f = f->next) { if (strcmp(f->name, name) == 0) @@ -345,23 +345,23 @@ void calcTextDimensions(const char *text, int size, int *w, int *h) int i; char *character; Glyph *g; - + scale = size / (FONT_SIZE * 1.0f); - + *w = 0; *h = 0; - + i = 0; - + character = nextCharacter(text, &i); - + while (character) { g = findGlyph(character); - + *w += g->rect.w * scale; *h = MAX(g->rect.h * scale, *h); - + character = nextCharacter(text, &i); } } @@ -370,56 +370,56 @@ int getWrappedTextHeight(char *text, int size) { char word[MAX_WORD_LENGTH]; int i, y, n, w, h, currentWidth, len; - + STRNCPY(drawTextBuffer, text, MAX_LINE_LENGTH); - + n = 0; y = 0; h = 0; currentWidth = 0; len = strlen(drawTextBuffer); memset(word, 0, MAX_WORD_LENGTH); - + for (i = 0 ; i < len ; i++) { word[n++] = drawTextBuffer[i]; - + if (drawTextBuffer[i] == ' ' || i == len - 1) { calcTextDimensions(word, size, &w, &h); - + if (currentWidth + w > app.textWidth) { currentWidth = 0; y += h; } - + currentWidth += w; - + memset(word, 0, MAX_WORD_LENGTH); - + n = 0; } } - + return y + h; } static char *nextCharacter(const char *str, int *i) { static char character[MAX_NAME_LENGTH]; - + unsigned char bit; int n; - + memset(character, '\0', MAX_NAME_LENGTH); - + n = 0; - + while (1) { bit = (unsigned char)str[*i]; - + if ((bit >= ' ' && bit <= '~') || bit >= 0xC0 || bit == '\0') { if (n > 0) @@ -427,9 +427,9 @@ static char *nextCharacter(const char *str, int *i) return character[0] != '\0' ? character : NULL; } } - + character[n++] = str[*i]; - + *i = *i + 1; } } diff --git a/src/system/text.h b/src/system/text.h index 6777ba4..e21960d 100644 --- a/src/system/text.h +++ b/src/system/text.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/system/textures.c b/src/system/textures.c index bc5e964..4c021b6 100644 --- a/src/system/textures.c +++ b/src/system/textures.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -52,7 +52,7 @@ static Texture *addTextureToCache(const char *name, SDL_Texture *texture) new->texture = texture; t->next = new; - + return new; } @@ -82,23 +82,23 @@ Texture *getTexture(const char *filename) return t; } } - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "%s not in texture cache", filename); - + return loadTexture(filename); } SDL_Texture *toTexture(SDL_Surface *surface, int destroySurface) { SDL_Texture *texture; - + texture = SDL_CreateTextureFromSurface(app.renderer, surface); - + if (destroySurface) { SDL_FreeSurface(surface); } - + return texture; } diff --git a/src/system/textures.h b/src/system/textures.h index 4cbb518..2e7e1c1 100644 --- a/src/system/textures.h +++ b/src/system/textures.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/system/transition.c b/src/system/transition.c index b88f0a9..a0b97dc 100644 --- a/src/system/transition.c +++ b/src/system/transition.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -27,9 +27,9 @@ void startSectionTransition(void) transitionStartTime = SDL_GetTicks(); prepareScene(); - + clearInput(); - + presentScene(); } diff --git a/src/system/widgets.c b/src/system/widgets.c index 835f489..830ca1c 100644 --- a/src/system/widgets.c +++ b/src/system/widgets.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -41,11 +41,11 @@ void initWidgets(void) memset(widgets, 0, sizeof(Widget) * MAX_WIDGETS); numWidgets = 0; - + selectedWidget = NULL; - + loadWidgets(); - + atlasTexture = getTexture("gfx/atlas/atlas.png"); left = getImageFromAtlas("gfx/ui/left.png"); right = getImageFromAtlas("gfx/ui/right.png"); @@ -93,7 +93,7 @@ void doWidgets(void) app.lastKeyPressed = 0; app.lastButtonPressed = -1; } - + app.keyboard[SDL_SCANCODE_SPACE] = app.keyboard[SDL_SCANCODE_RETURN] = 0; clearControl(CONTROL_FIRE); } @@ -132,7 +132,7 @@ static void handleInputWidget(void) { selectedWidget->value[0] = 0; selectedWidget->value[1] = -1; - + app.awaitingWidgetInput = 0; } else if (app.lastKeyPressed != 0 || app.lastButtonPressed != -1) @@ -141,12 +141,12 @@ static void handleInputWidget(void) { selectedWidget->value[0] = app.lastKeyPressed; } - + if (app.lastButtonPressed != -1) { selectedWidget->value[1] = app.lastButtonPressed; } - + app.awaitingWidgetInput = 0; } } @@ -159,7 +159,7 @@ void drawWidgets(void) for (i = 0 ; i < numWidgets ; i++) { w = &widgets[i]; - + if (w->visible) { if (w != selectedWidget) @@ -172,11 +172,11 @@ void drawWidgets(void) drawRect(w->x, w->y, w->w, w->h, 0, 128, 0, 255); drawOutlineRect(w->x, w->y, w->w, w->h, 0, 255, 0, 255); } - + drawText(w->x + w->w / 2, w->y + 2, 24, TA_CENTER, colors.white, w->label); - + outline = (w == selectedWidget) ? 255 : 192; - + switch (w->type) { case WT_SLIDER: @@ -189,17 +189,17 @@ void drawWidgets(void) for (j = 0 ; j < w->numOptions ; j++) { calcTextDimensions(w->options[j], 24, &tw, &th); - + tw += 25; - + if (j == w->value[0]) { drawRect(x, w->y, tw, w->h, 0, 128, 0, 255); drawOutlineRect(x, w->y, tw, w->h, 0, outline, 0, 255); } - + drawText(x + tw / 2, w->y + 2, 24, TA_CENTER, colors.white, w->options[j]); - + x += tw + 25; } break; @@ -208,7 +208,7 @@ void drawWidgets(void) x = w->x + w->w + 25; drawRect(x, w->y, 200, w->h, 0, 0, 0, 255); drawOutlineRect(x, w->y, 200, w->h, 0, outline, 0, 255); - + if (app.awaitingWidgetInput && w == selectedWidget) { drawText(x + 100, w->y + 2, 24, TA_CENTER, colors.white, "..."); @@ -227,7 +227,7 @@ void drawWidgets(void) } break; } - + if (w->disabled) { drawRect(w->x, w->y, w->w, w->h, 0, 0, 0, 160); @@ -239,17 +239,17 @@ void drawWidgets(void) void drawWidgetFrame(void) { drawRect(frame.x, frame.y, frame.w, frame.h, 0, 0, 0, 192); - + drawOutlineRect(frame.x, frame.y, frame.w, frame.h, 255, 255, 255, 255); } static void selectWidget(int dir) { int oldWidgetIndex, valid; - + oldWidgetIndex = widgetIndex; valid = 0; - + do { widgetIndex += dir; @@ -265,11 +265,11 @@ static void selectWidget(int dir) } selectedWidget = &widgets[widgetIndex]; - + valid = selectedWidget->visible && !selectedWidget->disabled; } while (!valid); - + if (oldWidgetIndex != widgetIndex) { playSound(SND_MENU_NAV, 0); @@ -280,17 +280,17 @@ Widget *getWidget(char *name, char *group) { int i; Widget *w; - + for (i = 0 ; i < numWidgets ; i++) { w = &widgets[i]; - + if (strcmp(w->name, name) == 0 && strcmp(w->group, group) == 0) { return w; } } - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "No such widget '%s', '%s'", name, group); exit(1); @@ -301,11 +301,11 @@ void setSelectedWidget(char *name, char *group) { Widget *w; int i; - + for (i = 0 ; i < numWidgets ; i++) { w = &widgets[i]; - + if (strcmp(w->name, name) == 0 && strcmp(w->group, group) == 0) { widgetIndex = i; @@ -328,36 +328,36 @@ Widget *selectWidgetAt(int x, int y) for (i = 0 ; i < numWidgets ; i++) { w = &widgets[i]; - + if (w->visible && collision(w->x, w->y, w->w, w->h, x, y, 1, 1)) { if (w != selectedWidget) { playSound(SND_MENU_NAV, 0); } - + widgetIndex = i; selectedWidget = w; return w; } } - + selectedWidget = NULL; - + return NULL; } void hideAllWidgets(void) { int i; - + for (i = 0 ; i < numWidgets ; i++) { widgets[i].visible = 0; } selectedWidget = NULL; - + frame.x = frame.y = frame.w = frame.h = 0; } @@ -365,16 +365,16 @@ void showWidgetGroup(char *group) { int i; Widget *w; - + hideAllWidgets(); - + frame.x = frame.y = UI_WIDTH; frame.w = frame.h = 0; - + for (i = 0 ; i < numWidgets ; i++) { w = &widgets[i]; - + if (strcmp(w->group, group) == 0) { if (selectedWidget == NULL) @@ -384,7 +384,7 @@ void showWidgetGroup(char *group) } w->visible = 1; - + frame.x = MIN(w->x - 25, frame.x); frame.y = MIN(w->y - 25, frame.y); frame.w = MAX(w->w + 50, frame.w); @@ -392,8 +392,8 @@ void showWidgetGroup(char *group) } } - - + + frame.h -= frame.y; } @@ -427,7 +427,7 @@ static void loadWidgetGroup(char *filename) text = readFile(filename); root = cJSON_Parse(text); - + for (node = root->child ; node != NULL ; node = node->next) { if (numWidgets >= MAX_WIDGETS) @@ -437,7 +437,7 @@ static void loadWidgetGroup(char *filename) } w = &widgets[numWidgets]; - + STRNCPY(w->name, cJSON_GetObjectItem(node, "name")->valuestring, MAX_NAME_LENGTH); STRNCPY(w->group, cJSON_GetObjectItem(node, "group")->valuestring, MAX_NAME_LENGTH); STRNCPY(w->label, _(cJSON_GetObjectItem(node, "label")->valuestring), MAX_NAME_LENGTH); @@ -446,35 +446,35 @@ static void loadWidgetGroup(char *filename) w->w = cJSON_GetObjectItem(node, "w")->valueint; w->h = cJSON_GetObjectItem(node, "h")->valueint; w->type = lookup(cJSON_GetObjectItem(node, "type")->valuestring); - + if (w->x == -1) { w->x = (UI_WIDTH - w->w) / 2; } - + switch (w->type) { case WT_SPINNER: createWidgetOptions(w, cJSON_GetObjectItem(node, "options")->valuestring); break; - + case WT_SLIDER: w->minValue = cJSON_GetObjectItem(node, "minValue")->valueint; w->maxValue = cJSON_GetObjectItem(node, "maxValue")->valueint; break; - + case WT_INPUT: break; - + default: break; } - + numWidgets++; } - + cJSON_Delete(root); - + free(text); } @@ -482,7 +482,7 @@ static void createWidgetOptions(Widget *w, char *options) { int i; char *option; - + w->numOptions = 1; for (i = 0 ; i < strlen(options) ; i++) @@ -501,7 +501,7 @@ static void createWidgetOptions(Widget *w, char *options) { w->options[i] = malloc(strlen(_(option)) + 1); strcpy(w->options[i], _(option)); - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "widget.option[%d] = %s", i, w->options[i]); option = strtok(NULL, "|"); diff --git a/src/system/widgets.h b/src/system/widgets.h index 57b74b8..70375ec 100644 --- a/src/system/widgets.h +++ b/src/system/widgets.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/test/worldTest.c b/src/test/worldTest.c index ad5f58e..feb705c 100644 --- a/src/test/worldTest.c +++ b/src/test/worldTest.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -19,17 +19,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "worldTest.h" - + void initWorldTest(char *worldId) { loadGame(0); - + saveGame(0); - + if (worldId != NULL) { STRNCPY(game.worldId, worldId, MAX_NAME_LENGTH); - + initWorld(); } else diff --git a/src/test/worldTest.h b/src/test/worldTest.h index 70bd3da..9daf4ac 100644 --- a/src/test/worldTest.h +++ b/src/test/worldTest.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/util/maths.c b/src/util/maths.c index 5f36565..5998ab1 100644 --- a/src/util/maths.c +++ b/src/util/maths.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -52,22 +52,22 @@ float limit(float i, float a, float b) { return a; } - + if (i > b) { return b; } - + return i; } int getDistance(int x1, int y1, int x2, int y2) { int x, y; - + x = x2 - x1; y = y2 - y1; - + return sqrt(x * x + y *y); } @@ -118,6 +118,6 @@ unsigned long hashcode(const char *str) } hash = ((hash << 5) + hash); - + return hash; } diff --git a/src/util/maths.h b/src/util/maths.h index 8ad0dc9..9e69b70 100644 --- a/src/util/maths.h +++ b/src/util/maths.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/util/util.c b/src/util/util.c index ae1eb76..9abbf71 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -53,16 +53,16 @@ char *timeToString(int seconds, int showHours) char *timeToDate(long millis) { static char DATE[MAX_NAME_LENGTH]; - + struct tm *timeinfo; time_t t; - + t = millis; - + timeinfo = localtime(&t); - + strftime(DATE, MAX_NAME_LENGTH, "%d %b %Y, %I:%M%p", timeinfo); - + return DATE; } @@ -70,14 +70,14 @@ void *resize(void *array, int oldSize, int newSize) { void **newArray; int copySize; - + copySize = newSize > oldSize ? oldSize : newSize; - + newArray = malloc(newSize); memset(newArray, 0, newSize); memcpy(newArray, array, copySize); free(array); - + return newArray; } @@ -85,22 +85,22 @@ char *buildFormattedString(const char *format, ...) { int n; char *s; - va_list args; - + va_list args; + va_start(args, format); n = vsnprintf(NULL, 0, format, args) + 1; va_end(args); - + s = malloc(sizeof(char) * n); - + va_start(args, format); vsprintf(s, format, args); va_end(args); - + return s; } -/* +/* * public domain strtok_r() by Charlie Gordon * * from comp.lang.c 9/14/2007 @@ -134,8 +134,8 @@ char *strtok_r(char *str, const char *delim, char **nextp) { *str++ = '\0'; } - + *nextp = str; - + return ret; } diff --git a/src/util/util.h b/src/util/util.h index 68290cd..f3ada11 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/camera.c b/src/world/camera.c index dd87bab..514a87d 100644 --- a/src/world/camera.c +++ b/src/world/camera.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -36,7 +36,7 @@ void cameraTrack(Entity *e) float cameraChase(Entity *e, int maxSpeed) { float x, y, tx, ty, diffX, diffY, dist; - + x = camera.x; y = camera.y; diff --git a/src/world/camera.h b/src/world/camera.h index ffd0873..aae12b9 100644 --- a/src/world/camera.h +++ b/src/world/camera.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/effects.c b/src/world/effects.c index ee00fc1..96bc1fa 100644 --- a/src/world/effects.c +++ b/src/world/effects.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -37,13 +37,13 @@ void initEffects(void) void addSmallFleshChunk(float x, float y) { Decoration *chunk; - + if (app.config.blood) { chunk = malloc(sizeof(Decoration)); memset(chunk, 0, sizeof(Decoration)); initFleshChunk(chunk); - + chunk->x = x; chunk->y = y; chunk->health = FPS / 4; @@ -62,13 +62,13 @@ void throwFleshChunks(float x, float y, int amount) Decoration *chunk; amount *= app.config.blood; - + for (i = 0; i < amount; i++) { chunk = malloc(sizeof(Decoration)); memset(chunk, 0, sizeof(Decoration)); initFleshChunk(chunk); - + chunk->x = x; chunk->y = y; chunk->dx = rrnd(-20, 20); diff --git a/src/world/effects.h b/src/world/effects.h index 36626ab..147d709 100644 --- a/src/world/effects.h +++ b/src/world/effects.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/entities.c b/src/world/entities.c index 01f1beb..9d680ab 100644 --- a/src/world/entities.c +++ b/src/world/entities.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -48,33 +48,33 @@ void initEntities(void) { int i; SDL_Rect *r; - + atlasTexture = getTexture("gfx/atlas/atlas.png"); - + for (i = 0 ; i < 3 ; i++) { memset(&targetMarker[i], 0, sizeof(Marker)); targetMarker[i].sprite = getSprite("Marker"); } - + for (self = world.entityHead.next ; self != NULL ; self = self->next) { - /* + /* * Most things retain their dimensions, so this isn't a big deal. If we set * this each frame, it will muck up the bouncing, especially in the case of grenades. */ if (self->w == 0 || self->h == 0) { r = &self->sprite[self->facing]->frames[self->spriteFrame]->rect; - + self->w = r->w; self->h = r->h; - + mirror(); } - + addToQuadtree(self, &world.quadtree); - + checkStuckInWall(); } } @@ -84,56 +84,56 @@ void doEntities(void) Entity *prev, *oldSelf, *e; int camMidX, camMidY, flicker, i; SDL_Rect *r; - + memset(riders, 0, sizeof(Entity*) * MAX_RIDERS); - + camMidX = camera.x + (app.config.winWidth / 2); camMidY = camera.y + (app.config.winHeight / 2); - + doMarker(&targetMarker[0], 1); doMarker(&targetMarker[1], -1); doMarker(&targetMarker[2], 1); - + flicker = world.frameCounter % 3 > 0; - + prev = &world.entityHead; - + for (self = world.entityHead.next ; self != NULL ; self = self->next) { if (self->w == 0 || self->h == 0) { r = &self->sprite[0]->frames[0]->rect; - + self->w = r->w; self->h = r->h; - + mirror(); } - + removeFromQuadtree(self, &world.quadtree); - + if (self->alive == ALIVE_DEAD) { prev->next = self->next; - + if (self == world.entityTail) { world.entityTail = prev; } - + free(self); - + /* assign prev entity to self */ self = prev; - + /* assign prev as self, so that prev doesn't point at the now freed memory */ prev = self; - + continue; } - + self->isVisible = 0; - + if (self->flags & EF_TELEPORTING) { world.saveDelay = FPS; @@ -141,7 +141,7 @@ void doEntities(void) prev = self; continue; } - + if ((self->flags & EF_ALWAYS_PROCESS) > 0 || getDistance(camMidX, camMidY, self->x, self->y) < app.config.winWidth || isObserving()) { self->isVisible = 1; @@ -152,7 +152,7 @@ void doEntities(void) } self->riding = NULL; - + if (self->isVisible) { memset(touched, 0, sizeof(Entity*) * MAX_TOUCHED); @@ -174,7 +174,7 @@ void doEntities(void) self->tick(); self->isOnGround = 0; - + if (self->dy >= 0 && (!(self->flags & EF_WEIGHTLESS))) { checkPlatformContact(); @@ -186,27 +186,27 @@ void doEntities(void) } self->animate(); - + for (i = 0 ; i < MAX_TOUCHED ; i++) { if (touched[i]) { self->touch(touched[i]); - + /* for objects that never move */ if (touched[i]->isStatic) { oldSelf = self; - + self = touched[i]; - + touched[i]->touch(oldSelf); - + self = oldSelf; } } } - + if (!(self->flags & EF_NO_ENVIRONMENT)) { compareEnvironments(); @@ -224,7 +224,7 @@ void doEntities(void) { self->isVisible = 0; } - + if (self->alive == ALIVE_ALIVE) { if (self->health <= 0) @@ -234,29 +234,29 @@ void doEntities(void) self->die(); } } - + if (self->alive == ALIVE_DYING) { world.saveDelay = FPS; } } - + if (!(self->flags & (EF_TELEPORTING | EF_GONE))) { addToQuadtree(self, &world.quadtree); } - + prev = self; } - + for (i = 0 ; i < MAX_RIDERS ; i++) { e = riders[i]; - + if (e != NULL) { removeFromQuadtree(e, &world.quadtree); - + if (e->dy > 0) { pushEntity(e, e->riding->dx, 0); @@ -264,7 +264,7 @@ void doEntities(void) if (!pushEntity(e, 0, e->riding->dy)) { e->riding->y -= e->riding->dy; - + if (e->flags & EF_CRUSHABLE) { e->health *= 0.5; @@ -273,7 +273,7 @@ void doEntities(void) e->y = e->riding->y - e->h; } - + addToQuadtree(e, &world.quadtree); } } @@ -282,10 +282,10 @@ void doEntities(void) void doEntitiesStatic(void) { int camMidX, camMidY; - + camMidX = camera.x + (app.config.winWidth / 2); camMidY = camera.y + (app.config.winHeight / 2); - + for (self = world.entityHead.next ; self != NULL ; self = self->next) { if (getDistance(camMidX, camMidY, self->x, self->y) < app.config.winWidth || isObserving()) @@ -306,29 +306,29 @@ void drawEntities(int plane) for (i = 0, self = candidates[i] ; self != NULL ; self = candidates[++i]) {}; qsort(candidates, i, sizeof(Entity*), drawComparator); - + for (i = 0, self = candidates[i] ; self != NULL ; self = candidates[++i]) { draw = self->isVisible && self->plane == plane; - + if (draw) { x = (-camera.x + self->x); y = (-camera.y + self->y); - + blitRect(atlasTexture->texture, x, y, self->getCurrentSprite(), 0); - + x += (self->w / 2) - 9; - + if (self->type == ET_ENEMY && ((Unit*)self)->carriedItem != NULL) { blitRect(atlasTexture->texture, x, y - (targetMarker[0].y + 5), &targetMarker[0].sprite->frames[0]->rect, 0); } - + if (self->isMissionTarget) { t = getMarkerType(); - + blitRect(atlasTexture->texture, x, y - (targetMarker[t].y + 5), &targetMarker[t].sprite->frames[t]->rect, 0); } } @@ -341,10 +341,10 @@ static int getMarkerType(void) { case ET_ENEMY: return 1; - + case ET_MIA: return 2; - + default: return 0; } @@ -356,7 +356,7 @@ static void checkPlatformContact(void) Entity **candidates; int i; SDL_Rect srcRect; - + srcRect.x = self->x; srcRect.y = self->y; srcRect.w = self->w; @@ -387,7 +387,7 @@ static void checkPlatformContact(void) static void moveEntity(void) { PointF position; - + switch (self->environment) { case ENV_AIR: @@ -456,15 +456,15 @@ static void moveEntity(void) static void checkStuckInWall(void) { int mx, my; - + mx = self->x / MAP_TILE_SIZE; my = self->y / MAP_TILE_SIZE; - + if (!isWithinMap(mx, my)) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "%s (%d) outside world at %d,%d", self->name, self->type, mx, my); } - + switch (self->type) { case ET_PRESSURE_PLATE: @@ -472,16 +472,16 @@ static void checkStuckInWall(void) case ET_DOOR: case ET_ITEM_PAD: break; - + default: if (hasHitWorld(mx, my)) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "%s (%d): in wall at %d,%d", self->name, self->type, mx, my); - + if (self->type == ET_KEY || self->type == ET_ITEM) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "Attempting to reset stuck item"); - + self->reset(); } } @@ -493,7 +493,7 @@ static void haltAtEdge(void) { float x, y; int mx, my, i; - + if (!(self->flags & (EF_WEIGHTLESS | EF_SWIMS))) { if (self->environment == ENV_WATER) @@ -579,7 +579,7 @@ static int canWalkOnEntity(float x, float y) Entity *e; Entity **candidates; SDL_Rect srcRect; - + srcRect.x = x; srcRect.y = y; srcRect.w = self->w; @@ -604,7 +604,7 @@ static void moveToOthers(float dx, float dy, PointF *position) Entity **candidates; int clearTouched, hit, dirX, dirY, solidLoopHits, i; SDL_Rect srcRect, destRect; - + self->getCollisionBounds(&srcRect); srcRect.x = (int) position->x; srcRect.y = (int) position->y; @@ -627,7 +627,7 @@ static void moveToOthers(float dx, float dy, PointF *position) { continue; } - + oldSelf = self; self = e; e->getCollisionBounds(&destRect); @@ -644,7 +644,7 @@ static void moveToOthers(float dx, float dy, PointF *position) if (self->type == ET_BOB && e->type == ET_PUSHBLOCK && dx != 0) { removeFromQuadtree(e, &world.quadtree); - + if (!pushEntity(e, dx * 0.35, 0)) { position->x = e->x; @@ -655,7 +655,7 @@ static void moveToOthers(float dx, float dy, PointF *position) { self->animate(); } - + addToQuadtree(e, &world.quadtree); } @@ -701,7 +701,7 @@ static void moveToOthers(float dx, float dy, PointF *position) } clearTouched = 1; - + self->getCollisionBounds(&srcRect); } while (hit); @@ -712,15 +712,15 @@ static int pushEntity(Entity *e, float dx, float dy) float expectedX, expectedY; PointF position; Entity *oldSelf; - + expectedX = e->x + dx; expectedY = e->y + dy; position.x = e->x; position.y = e->y; - + oldSelf = self; - + self = e; if (dx != 0) @@ -738,7 +738,7 @@ static int pushEntity(Entity *e, float dx, float dy) moveToMap(0, dy, &position); e->y = position.y; } - + self = oldSelf; return (e->x == expectedX && e->y == expectedY); @@ -747,11 +747,11 @@ static int pushEntity(Entity *e, float dx, float dy) static void moveToMap(float dx, float dy, PointF *position) { int i, mx, my, width, height, adjX, adjY, hit; - + width = self->w; height = self->h; adjX = adjY = 0; - + if (self->flags & EF_NO_CLIP) { return; @@ -825,7 +825,7 @@ static void moveToMap(float dx, float dy, PointF *position) { self->isOnGround = 1; } - + position->y = (my * MAP_TILE_SIZE) - adjY; self->dy = self->bounce(self->dy); self->dy = limit(self->dy, JUMP_POWER, -JUMP_POWER); @@ -853,7 +853,7 @@ static int hasHitWorld(int mx, int my) static void compareEnvironments(void) { int prevEnv, x, y; - + prevEnv = self->environment; self->environment = ENV_AIR; @@ -907,7 +907,7 @@ static void compareEnvironments(void) playBattleSound(SND_SLIME, self->uniqueId % MAX_SND_CHANNELS, self->x, self->y); } break; - + default: break; } @@ -918,7 +918,7 @@ static void compareEnvironments(void) static int isObserving(void) { int i; - + for (i = 0 ; i < MAX_ENTS_TO_OBSERVE ; i++) { if (world.entitiesToObserve[i] == self) @@ -926,7 +926,7 @@ static int isObserving(void) return 1; } } - + return 0; } @@ -934,9 +934,9 @@ void activateEntities(char *nameList, int active) { Entity *oldSelf; char *name, names[MAX_DESCRIPTION_LENGTH]; - + STRNCPY(names, nameList, MAX_DESCRIPTION_LENGTH); - + oldSelf = self; name = strtok(names, "|"); @@ -944,7 +944,7 @@ void activateEntities(char *nameList, int active) while (name) { SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Activate '%s'", name); - + for (self = world.entityHead.next ; self != NULL ; self = self->next) { if (strcmp(self->name, name) == 0) @@ -955,7 +955,7 @@ void activateEntities(char *nameList, int active) name = strtok(NULL, "|"); } - + self = oldSelf; } @@ -972,7 +972,7 @@ void teleportEntity(Entity *e, float tx, float ty) static void handleTeleport(void) { float diffX, diffY; - + diffX = fabs(self->x - self->tx) / 20; diffY = fabs(self->y - self->ty) / 20; @@ -1011,7 +1011,7 @@ static void handleTeleport(void) self->environment = ENV_AIR; self->changeEnvironment(); playBattleSound(SND_TELEPORT, self->uniqueId % MAX_SND_CHANNELS, self->x, self->y); - + if (self == (Entity*)world.bob) { terminateJetpack(); @@ -1023,13 +1023,13 @@ void dropCarriedItem(void) { EntityExt *e; Item *i; - + e = (EntityExt*)self; - + if (e->carriedItem != NULL) { i = e->carriedItem; - + i->x = (e->x + e->w / 2) - i->w / 2; i->y = e->y; @@ -1050,11 +1050,11 @@ void teleport(Entity *e, float tx, float ty) e->flags |= EF_TELEPORTING; addTeleportStars(e); - + if (e == (Entity*)world.bob) { terminateJetpack(); - + world.bob->flags &= ~(EF_WATER_BREATHING | EF_WEIGHTLESS); } } @@ -1062,7 +1062,7 @@ void teleport(Entity *e, float tx, float ty) Entity *getRandomObjectiveEntity(void) { Entity *rtn, *e; - + rtn = (Entity*)world.bob; for (e = world.entityHead.next ; e != NULL ; e = e->next) @@ -1079,7 +1079,7 @@ Entity *getRandomObjectiveEntity(void) static void doMarker(Marker *m, int delta) { int i; - + for (i = 0 ; i < 3 ; i++) { m->value -= (0.05 * delta); @@ -1090,7 +1090,7 @@ static void doMarker(Marker *m, int delta) static void addRider(void) { int i; - + for (i = 0 ; i < MAX_RIDERS ; i++) { if (!riders[i]) @@ -1106,7 +1106,7 @@ static void addRider(void) static void addTouched(Entity *e) { int i; - + for (i = 0 ; i < MAX_TOUCHED ; i++) { if (!touched[i]) @@ -1122,7 +1122,7 @@ static void addTouched(Entity *e) void swapSelf(Entity *e) { static Entity *oldSelf = NULL; - + if (!oldSelf) { oldSelf = self; @@ -1147,7 +1147,7 @@ static void mirror(void) { Structure *s; Item *i; - + if (self->flags & EF_MIRROR) { switch (self->type) @@ -1160,7 +1160,7 @@ static void mirror(void) s->tx -= self->w; } break; - + case ET_LIFT: s = (Structure*)self; if (s->startX == s->x) @@ -1169,12 +1169,12 @@ static void mirror(void) s->tx -= self->w; } break; - + case ET_TELEPORTER: s = (Structure*)self; s->tx -= self->w; break; - + case ET_PUSHBLOCK: s = (Structure*)self; if (s->x != s->startX) @@ -1183,19 +1183,19 @@ static void mirror(void) s->startX -= self->w; } break; - + case ET_ITEM: case ET_KEY: i = (Item*)self; i->startX -= self->w; break; - + default: break; } - + self->x -= self->w; - + self->flags &= ~EF_MIRROR; } } diff --git a/src/world/entities.h b/src/world/entities.h index fe93b35..b104b50 100644 --- a/src/world/entities.h +++ b/src/world/entities.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/hud.c b/src/world/hud.c index ee0b39a..1aee922 100644 --- a/src/world/hud.c +++ b/src/world/hud.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -43,7 +43,7 @@ void initHud(void) messageType = MSG_STANDARD; strcpy(message, ""); messageColor = colors.white; - + atlasTexture = getTexture("gfx/atlas/atlas.png"); healthIcon = getImageFromAtlas("gfx/hud/health.png"); powerIcon = getImageFromAtlas("gfx/hud/power.png"); @@ -58,7 +58,7 @@ void doHud(void) messageTime = 0; strcpy(message, ""); } - + if (--infoMessageTime <= 0) { infoMessageTime = 0; @@ -68,20 +68,20 @@ void doHud(void) void drawHud(void) { int x, y, h; - + drawHealth(); - + drawPower(); - + drawOxygen(); - + drawText(10, 82, 16, TA_LEFT, colors.white, app.strings[ST_WEAPON], getWeaponName(world.bob->weaponType)); - + if (app.config.inventory) { drawInventory(); } - + if (world.isBossActive) { drawBossHealth(); @@ -89,10 +89,10 @@ void drawHud(void) else if (messageTime > 0) { drawRect(0, app.config.winHeight - 32, app.config.winWidth, 32, 0, 0, 0, 200); - + drawText(app.config.winWidth / 2, app.config.winHeight - 26, 16, TA_CENTER, messageColor, message); } - + if (infoMessageTime > 0) { app.textWidth = 500; @@ -102,12 +102,12 @@ void drawHud(void) drawText(app.config.winWidth / 2, 50, 20, TA_CENTER, colors.white, infoMessage); app.textWidth = 0; } - + if (dev.debug) { x = -camera.x + world.bob->x + (world.bob->w / 2); y = -camera.y + world.bob->y - world.bob->h; - + drawText(x, y, 14, TA_CENTER, colors.white, "[%.0f, %.0f]", world.bob->x / MAP_TILE_SIZE, world.bob->y / MAP_TILE_SIZE); } } @@ -115,76 +115,76 @@ void drawHud(void) static void drawHealth(void) { int w, health, healthMax; - + health = MAX(0, world.bob->health); healthMax = MIN(world.bob->healthMax, 50); - + blitRect(atlasTexture->texture, 17, 17, &healthIcon->rect, 1); - + w = healthMax * 12; - + drawRect(35, 8, w, 18, 0, 64, 0, 255); - + w *= ((health * 1.0) / world.bob->healthMax); - + drawRect(35, 8, w, 18, 0, 225, 0, 255); if (world.frameCounter % 60 < 30 && getPercent(health, world.bob->healthMax) <= 33) { drawRect(35, 8, w, 18, 255, 225, 255, 255); } - + w = healthMax * 12; - + drawOutlineRect(35, 8, w, 18, 0, 0, 0, 255); - + drawText(35 + w + 5, 7, 14, TA_LEFT, colors.white, "%d", health); } static void drawPower(void) { float w, powerMax; - + powerMax = MIN(world.bob->powerMax, 50); - + blitRect(atlasTexture->texture, 17, 42, &powerIcon->rect, 1); - + w = powerMax * 12; - + drawRect(35, 33, w, 18, 64, 32, 0, 255); - + w *= (world.bob->power / world.bob->powerMax); - + drawRect(35, 33, w, 18, 225, 112, 0, 255); - + w = powerMax * 12; - + drawOutlineRect(35, 33, w, 18, 0, 0, 0, 255); - + drawText(35 + w + 5, 32, 14, TA_LEFT, colors.white, "%.1f", world.bob->power); } static void drawOxygen(void) { int w; - + blitRect(atlasTexture->texture, 17, 67, &oxygenIcon->rect, 1); - + w = MAX_OXYGEN / 5; - + drawRect(35, 58, w, 18, 0, 32, 64, 255); - + w = world.bob->oxygen / 5; - + drawRect(35, 58, w, 18, 0, 112, 225, 255); if (world.frameCounter % 60 < 30 && getPercent(world.bob->oxygen, MAX_OXYGEN) <= 33) { drawRect(35, 58, w, 18, 255, 225, 255, 255); } - + w = MAX_OXYGEN / 5; - + drawOutlineRect(35, 58, w, 18, 0, 0, 0, 255); - + drawText(35 + w + 5, 57, 14, TA_LEFT, colors.white, "%.1fs", (world.bob->oxygen * 1.0) / FPS); } @@ -193,13 +193,13 @@ static void drawInventory(void) int x, y, i, size, mid; float w, h, d; SDL_Rect *r; - + size = 45; mid = size / 2; - + x = app.config.winWidth - 350; y = 5; - + for (i = 0 ; i < MAX_ITEMS ; i++) { if (i > 0 && i % (MAX_ITEMS / 2) == 0) @@ -207,30 +207,30 @@ static void drawInventory(void) y += (size + 5); x = app.config.winWidth - 350; } - + drawRect(x, y, size, size, 0, 0, 0, 128); - + drawOutlineRect(x, y, size, size, 255, 255, 255, 255); - + if (world.bob->items[i] != NULL) { r = getCurrentFrame(world.bob->items[i]->sprite[0]); - + w = r->w; h = r->h; - + if (w > 40 || h > 40) { d = 40; d /= (w > h) ? w : h; - + w *= d; h *= d; } - + blitRectScaled(atlasTexture->texture, x + mid, y + mid, w, h, r, 1); } - + x += (size + 5); } } @@ -239,19 +239,19 @@ static void drawBossHealth(void) { float percent; int w, x; - + percent = world.boss->health; percent /= world.boss->healthMax; - + w = MAX(500 * percent, 0); - + x = (app.config.winWidth - 500) / 2; x += 100; - + drawRect(0, app.config.winHeight - 32, app.config.winWidth, 32, 0, 0, 0, 200); - + drawText(x, app.config.winHeight - 28, 16, TA_RIGHT, colors.white, world.boss->name); - + drawRect(x + 10, app.config.winHeight - 24, w, 16, 255, 0, 0, 255); drawOutlineRect(x + 10, app.config.winHeight - 24, 500, 16, 192, 192, 192, 255); } @@ -264,55 +264,55 @@ void drawMissionStatus(int showFirePrompt) SDL_Color c; SDL_Rect *r; char *status; - + drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128); - + SDL_SetRenderTarget(app.renderer, app.uiBuffer); - + w = 800; h = 550; x = (UI_WIDTH - w) / 2; - + drawRect(x, (UI_HEIGHT - h) / 2, w, h, 0, 0, 0, 128); drawOutlineRect(x, (UI_HEIGHT - h) / 2, w, h, 255, 255, 255, 200); - + drawText(UI_WIDTH / 2, 100, 40, TA_CENTER, colors.white, app.strings[ST_OBJECTIVES]); - + y = 180; textSize = 24; lineSpacing = 55; - + if (world.numObjectives > 5) { textSize -= (world.numObjectives - 5) * 2; lineSpacing -= (world.numObjectives - 5) * 8; } - + for (o = world.objectiveHead.next ; o != NULL ; o = o->next) { c = o->required ? colors.red : colors.white; status = app.strings[ST_INCOMPLETE]; - + if (o->currentValue >= o->targetValue) { c = colors.green; status = app.strings[ST_COMPLETE]; } - + drawText(x + 20, y, textSize, TA_LEFT, c, o->description); drawText(UI_WIDTH / 2 + 100, y, textSize, TA_LEFT, c, "%d / %d", MIN(o->currentValue, o->targetValue), o->targetValue); drawText(x + w - 20, y, textSize, TA_RIGHT, c, status); - + y += lineSpacing; } - + size = 60; mid = size / 2; - + y = (((UI_HEIGHT - h) / 2) + h) - 165; - + x = ((UI_WIDTH - w) / 2) + 90; - + for (i = 0 ; i < MAX_ITEMS ; i++) { if (i > 0 && i % (MAX_ITEMS / 2) == 0) @@ -320,43 +320,43 @@ void drawMissionStatus(int showFirePrompt) y += (size + 20); x = ((UI_WIDTH - w) / 2) + 90; } - + drawRect(x, y, size, size, 0, 0, 0, 128); - + drawOutlineRect(x, y, size, size, 255, 255, 255, 255); - + if (world.bob->items[i] != NULL) { r = getCurrentFrame(world.bob->items[i]->sprite[0]); - + rw = r->w; rh = r->h; - + if (rw > 40 || rh > 40) { d = 40; d /= (rw > rh) ? rw : rh; - + rw *= d; rh *= d; } - + blitRectScaled(atlasTexture->texture, x + mid, y + mid, rw, rh, r, 1); - + if (world.bob->items[i]->value > 0) { drawText(x + size - 5, y, 14, TA_RIGHT, colors.white, "%d", world.bob->items[i]->value); } } - + x += (size + 30); } - + if (showFirePrompt) { drawText(UI_WIDTH / 2, UI_HEIGHT - 80, 24, TA_CENTER, colors.white, app.strings[ST_PRESS_FIRE]); } - + SDL_SetRenderTarget(app.renderer, app.backBuffer); } @@ -370,26 +370,26 @@ void setGameplayMessage(int newMessageType, const char *format, ...) va_start(args, format); vsprintf(newMessage, format, args); va_end(args); - + if (strlen(newMessage) > 0 && newMessageType >= messageType && strcmp(message, newMessage)) { STRNCPY(message, newMessage, MAX_DESCRIPTION_LENGTH); messageType = newMessageType; messageTime = FPS * 3; - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "%s", message); - + switch (messageType) { case MSG_STANDARD: case MSG_GAMEPLAY: messageColor = colors.white; break; - + case MSG_PROGRESS: messageColor = colors.cyan; break; - + case MSG_OBJECTIVE: messageColor = colors.green; break; diff --git a/src/world/hud.h b/src/world/hud.h index 13745ba..4e47af5 100644 --- a/src/world/hud.h +++ b/src/world/hud.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/items.c b/src/world/items.c index 9995e6b..b20d928 100644 --- a/src/world/items.c +++ b/src/world/items.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -43,12 +43,12 @@ void addRandomWeapon(int x, int y) int type; i = initWeaponPickup(); - + i->x = x; i->y = y; - + type = getRandomPlayerWeaponAt(i->x, i->y); - + i->weaponType = type; i->sprite[0] = i->sprite[1] = i->sprite[2] = wpnIconSprite; i->spriteFrame = type; @@ -60,9 +60,9 @@ void addRandomWeapon(int x, int y) static int getRandomPlayerWeaponAt(int x, int y) { int type; - + type = getRandomPlayerWeapon(world.missionType == MT_BOSS); - + if (world.map.data[(x / MAP_TILE_SIZE)][(y / MAP_TILE_SIZE)] == MAP_TILE_WATER) { type = WPN_PISTOL; @@ -71,7 +71,7 @@ static int getRandomPlayerWeaponAt(int x, int y) { type = getRandomPlayerWeapon(world.missionType == MT_BOSS); } - + return type; } @@ -81,7 +81,7 @@ void dropRandomCherry(int x, int y) int r; i = initCherry(); - + r = rand() % 100; if (r < 1) @@ -114,7 +114,7 @@ static void dropBattery(int x, int y) { Item *i; int r; - + i = initBattery(); r = rand() % 100; @@ -143,10 +143,10 @@ static void dropBattery(int x, int y) i->sprite[0] = i->sprite[1] = i->sprite[2] = batterySprite; i->spriteTime = -1; i->spriteFrame = i->power; - + i->x = x; i->y = y; - + i->animate(); throwItem(i); diff --git a/src/world/items.h b/src/world/items.h index 13f7a89..bd510a9 100644 --- a/src/world/items.h +++ b/src/world/items.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/map.c b/src/world/map.c index affcd51..55f561c 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -35,30 +35,30 @@ static SDL_Rect *decals[8]; void initMap(void) { memset(&world.map, 0, sizeof(Map)); - + world.map.bounds.x = MAP_WIDTH * MAP_TILE_SIZE; world.map.bounds.y = MAP_HEIGHT * MAP_TILE_SIZE; world.map.bounds.w = 0; world.map.bounds.h = 0; - + atlasTexture = getTexture("gfx/atlas/atlas.png"); - + loadMapData(); - + loadCommonTiles(); - + loadTileset(); - + loadDecals(); } void drawMap(void) { int mx, x1, x2, my, y1, y2, tile, decal, x, y, renderWidth, renderHeight; - + renderWidth = (app.config.winWidth / MAP_TILE_SIZE) + 1; renderHeight = (app.config.winHeight / MAP_TILE_SIZE) + 1; - + mx = camera.x / MAP_TILE_SIZE; x1 = (camera.x % MAP_TILE_SIZE) * -1; x2 = x1 + renderWidth * MAP_TILE_SIZE + (x1 == 0 ? 0 : MAP_TILE_SIZE); @@ -102,7 +102,7 @@ void drawMap(void) { blitRect(atlasTexture->texture, x + 2, y + 2, tiles[MAP_TILE_OUTSIDE], 0); } - + blitRect(atlasTexture->texture, x, y, tiles[tile], 0); decal = world.map.decal[mx][my]; @@ -175,10 +175,10 @@ int isWalkable(int x, int y) static void calculateMapBounds(void) { int x, y, renderWidth, renderHeight; - + renderWidth = (app.config.winWidth / MAP_TILE_SIZE) + 1; renderHeight = (app.config.winHeight / MAP_TILE_SIZE) + 1; - + for (y = 0 ; y < MAP_HEIGHT; y++) { for (x = 0 ; x < MAP_WIDTH; x++) @@ -226,9 +226,9 @@ static void calculateMapBounds(void) world.map.bounds.w += MAP_TILE_SIZE; world.map.bounds.h += MAP_TILE_SIZE; - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Map bounds [%d, %d, %d, %d]", world.map.bounds.x, world.map.bounds.y, world.map.bounds.w, world.map.bounds.h); - + MAX_Y = 0; for (y = 0; y < MAP_HEIGHT; y++) @@ -251,21 +251,21 @@ static void loadMapData(void) char filename[MAX_FILENAME_LENGTH]; char *data, *p; int i, x, y; - + sprintf(filename, "data/maps/raw/%s.raw.z", world.id); - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Loading %s", filename); - + data = readCompressedFile(filename); - + p = data; - + for (y = 0 ; y < MAP_HEIGHT ; y++) { for (x = 0 ; x < MAP_WIDTH ; x++) { i = atoi(p); - + if (world.missionType != MT_OUTPOST) { if (i >= 4 && i <= 7) @@ -285,36 +285,36 @@ static void loadMapData(void) { i = rrnd(200, 203); } - + world.map.data[x][y] = i; - + do {p++;} while (*p != ' '); } } - + free(data); - + if (game.plus & PLUS_MIRROR) { mirrorMap(); } - + calculateMapBounds(); } static void mirrorMap(void) { int x, y, w, t1, t2; - + w = MAP_WIDTH - 1; - + for (y = 0 ; y < MAP_HEIGHT ; y++) { for (x = 0 ; x < MAP_WIDTH / 2 ; x++) { t1 = world.map.data[x][y]; t2 = world.map.data[w - x][y]; - + world.map.data[x][y] = t2; world.map.data[w - x][y] = t1; } @@ -325,7 +325,7 @@ static void loadCommonTiles(void) { int i; char filename[MAX_FILENAME_LENGTH]; - + tiles[1] = loadTile("gfx/tiles/common/1.png"); tiles[2] = loadTile("gfx/tiles/common/2.png"); tiles[3] = loadTile("gfx/tiles/common/3.png"); @@ -341,11 +341,11 @@ static void loadTileset(void) { int i; char filename[MAX_FILENAME_LENGTH]; - + for (i = MAP_TILE_SOLID ; i < MAP_TILE_ANIMATED_WATER ; i++) { sprintf(filename, "gfx/tiles/%s/%d.png", world.tileset, i); - + tiles[i] = loadTile(filename); } } @@ -359,12 +359,12 @@ static void loadDecals(void) { int i; char filename[MAX_FILENAME_LENGTH]; - + for (i = 0 ; i < 4 ; i++) { sprintf(filename, "gfx/decals/blood%d.png", (i + 1)); decals[i] = loadTile(filename); - + sprintf(filename, "gfx/decals/scorch%d.png", (i + 1)); decals[i + 4] = loadTile(filename); } diff --git a/src/world/map.h b/src/world/map.h index c9c011e..d0194a6 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/objectives.c b/src/world/objectives.c index ed9e036..9c9586f 100644 --- a/src/world/objectives.c +++ b/src/world/objectives.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -26,9 +26,9 @@ void initObjectives(void) { int totalTargets; Objective *o; - + world.isReturnVisit = world.currentStatus == MS_PARTIAL || world.currentStatus == MS_MISSING_HEART_CELL || game.isComplete; - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "world.isReturnVisit = %d", world.isReturnVisit); for (o = world.objectiveHead.next ; o != NULL ; o = o->next) @@ -57,7 +57,7 @@ void initObjectives(void) o->targetValue = o->totalValue; o->required = game.isComplete; } - + if ((strcmp(o->targetName, "ENEMY") == 0 && o->targetValue == o->totalValue) || game.plus & PLUS_KILL_ALL) { world.isEliminateAllEnemies = 1; @@ -69,7 +69,7 @@ static int countTargetsInWorld(char *targetName) { int num, countMIAs, countEnemies, countKeys; Entity *e; - + num = 0; countMIAs = strcmp(targetName, "MIA") == 0; countEnemies = strcmp(targetName, "ENEMY") == 0; @@ -104,7 +104,7 @@ static int countTargetsInWorld(char *targetName) void updateObjective(char *targetName) { Objective *o; - + if (world.currentStatus != MS_MISSING_HEART_CELL) { for (o = world.objectiveHead.next ; o != NULL ; o = o->next) @@ -157,7 +157,7 @@ void updateObjective(char *targetName) void updateHeartCellObjective(void) { Entity *e; - + for (e = world.entityHead.next ; e != NULL ; e = e->next) { if (e->alive == ALIVE_ALIVE) diff --git a/src/world/objectives.h b/src/world/objectives.h index 89d7eb2..54ca7df 100644 --- a/src/world/objectives.h +++ b/src/world/objectives.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/particles.c b/src/world/particles.c index c543f68..7c0b5ab 100644 --- a/src/world/particles.c +++ b/src/world/particles.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -43,7 +43,7 @@ void initParticles(void) smokeSprite = getSprite("Smoke"); teleportStarSprite = getSprite("TeleportStar"); - + atlasTexture = getTexture("gfx/atlas/atlas.png"); } @@ -51,10 +51,10 @@ void doParticles(void) { Particle *p, *prev; int camMidX, camMidY; - + camMidX = camera.x + (app.config.winWidth / 2); camMidY = camera.y + (app.config.winHeight / 2); - + prev = &world.particleHead; for (p = world.particleHead.next ; p != NULL ; p = p->next) @@ -63,7 +63,7 @@ void doParticles(void) p->x += p->dx; p->y += p->dy; - + p->onScreen = 0; if (--p->health <= 0 || (p->destroyAfterAnim && p->spriteTime == -1)) @@ -72,7 +72,7 @@ void doParticles(void) { world.particleTail = prev; } - + prev->next = p->next; free(p); p = prev; @@ -81,7 +81,7 @@ void doParticles(void) { p->onScreen = 1; } - + prev = p; } } @@ -90,7 +90,7 @@ void drawParticles(int plane) { Particle *p; int x, y; - + for (p = world.particleHead.next ; p != NULL ; p = p->next) { if (p->onScreen && p->plane == plane) @@ -117,7 +117,7 @@ void drawParticles(int plane) void addBlood(float x, float y) { Particle *p; - + p = createParticle(); p->type = PT_TEXTURED; p->x = x; @@ -132,7 +132,7 @@ void addSparkParticles(float x, float y) { Particle *p; int i; - + for (i = 0; i < 3; i++) { p = createParticle(); @@ -141,7 +141,7 @@ void addSparkParticles(float x, float y) p->dx = (randF() - randF()) * 3; p->dy = (randF() - randF()) * 3; p->health = rrnd(5, 30); - + p->r = p->g = p->b = rrnd(128, 255); } } @@ -149,7 +149,7 @@ void addSparkParticles(float x, float y) void addSmokeParticles(float x, float y, int rising) { Particle *p; - + p = createParticle(); p->type = PT_TEXTURED; p->x = x; @@ -160,7 +160,7 @@ void addSmokeParticles(float x, float y, int rising) p->spriteTime = 5; p->spriteFrame = 0; p->destroyAfterAnim = 1; - + if (rising) { p->dy = rrnd(-5, -1); @@ -170,7 +170,7 @@ void addSmokeParticles(float x, float y, int rising) void addFlameParticles(float x, float y, int rising) { Particle *p; - + p = createParticle(); p->type = PT_TEXTURED; p->x = x; @@ -181,7 +181,7 @@ void addFlameParticles(float x, float y, int rising) p->spriteTime = 5; p->spriteFrame = 0; p->destroyAfterAnim = 1; - + if (rising) { p->dy = rrnd(-5, -1); @@ -192,7 +192,7 @@ void addExplosionParticles(float x, float y, float radius, int amount) { int i; Particle *p; - + for (i = 0; i < amount; i++) { p = createParticle(); @@ -214,7 +214,7 @@ void addPopParticles(float x, float y) { int i; Particle *p; - + for (i = 0; i < 12; i++) { p = createParticle(); @@ -235,7 +235,7 @@ void addPopParticles(float x, float y) void addTeleportStar(float x, float y) { Particle *p; - + p = createParticle(); p->type = PT_TEXTURED; p->x = x; @@ -252,7 +252,7 @@ void addTeleportStar(float x, float y) void addTeleportStars(Entity *e) { int x, y, i; - + x = (int) (e->x + (e->w / 2)); y = (int) (e->y + (e->h / 2)); @@ -265,7 +265,7 @@ void addTeleportStars(Entity *e) void addMIATeleportStars(float x, float y) { Particle *p; - + p = createParticle(); p->type = PT_TEXTURED; p->x = x; @@ -281,7 +281,7 @@ void addMIATeleportStars(float x, float y) void addTeleporterEffect(float x, float y) { Particle *p; - + p = createParticle(); p->type = PT_TEXTURED; p->x = x; @@ -297,9 +297,9 @@ void addTeleporterEffect(float x, float y) static void animate(Particle *p) { Sprite *s; - + s = p->sprite; - + if (p->spriteTime != -1) { if (--p->spriteTime <= 0) @@ -308,7 +308,7 @@ static void animate(Particle *p) { p->spriteFrame = 0; } - + p->spriteTime = p->sprite->times[p->spriteFrame]; } } @@ -317,14 +317,14 @@ static void animate(Particle *p) static Particle *createParticle(void) { Particle *p; - + p = malloc(sizeof(Particle)); memset(p, 0, sizeof(Particle)); world.particleTail->next = p; world.particleTail = p; - + p->spriteTime = -1; - + return p; } diff --git a/src/world/particles.h b/src/world/particles.h index 8c7f2c4..ca23738 100644 --- a/src/world/particles.h +++ b/src/world/particles.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/player.c b/src/world/player.c index 8f73f79..b9919fb 100644 --- a/src/world/player.c +++ b/src/world/player.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -36,27 +36,27 @@ static void doDebugControls(void) { world.bob->weaponType = WPN_PISTOL; } - + if (app.keyboard[SDL_SCANCODE_2]) { world.bob->weaponType = WPN_PLASMA; } - + if (app.keyboard[SDL_SCANCODE_3]) { world.bob->weaponType = WPN_SPREAD; } - + if (app.keyboard[SDL_SCANCODE_4]) { world.bob->weaponType = WPN_LASER; } - + if (app.keyboard[SDL_SCANCODE_5]) { world.bob->weaponType = WPN_GRENADES; } - + if (app.keyboard[SDL_SCANCODE_0] && world.state != WS_COMPLETE) { quitMission(); diff --git a/src/world/player.h b/src/world/player.h index 743291a..98d9634 100644 --- a/src/world/player.h +++ b/src/world/player.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/quadtree.c b/src/world/quadtree.c index 6c415a5..fcf7ef5 100644 --- a/src/world/quadtree.c +++ b/src/world/quadtree.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -36,7 +36,7 @@ void initQuadtree(Quadtree *root) { Quadtree *node; int i, w, h; - + /* entire map */ if (root->depth == 0) { @@ -45,16 +45,16 @@ void initQuadtree(Quadtree *root) root->capacity = QT_INITIAL_CAPACITY; root->ents = malloc(sizeof(Entity*) * root->capacity); memset(root->ents, 0, sizeof(Entity*) * root->capacity); - + cIndex = 0; cCapacity = QT_INITIAL_CAPACITY; candidates = malloc(sizeof(Entity*) * cCapacity); memset(candidates, 0, sizeof(Entity*) * cCapacity); } - + w = root->w / 2; h = root->h / 2; - + if (root->depth + 1 < QT_MAX_DEPTH) { for (i = 0 ; i < 4 ; i++) @@ -62,12 +62,12 @@ void initQuadtree(Quadtree *root) node = malloc(sizeof(Quadtree)); memset(node, 0, sizeof(Quadtree)); root->node[i] = node; - + node->depth = root->depth + 1; node->capacity = QT_INITIAL_CAPACITY; node->ents = malloc(sizeof(Entity*) * node->capacity); memset(node->ents, 0, sizeof(Entity*) * node->capacity); - + switch (i) { case 0: @@ -76,7 +76,7 @@ void initQuadtree(Quadtree *root) node->w = w; node->h = h; break; - + case 1: node->x = root->x + w; node->y = root->y; @@ -90,7 +90,7 @@ void initQuadtree(Quadtree *root) node->w = w; node->h = h; break; - + default: node->x = root->x + w; node->y = root->y + h; @@ -98,7 +98,7 @@ void initQuadtree(Quadtree *root) node->h = h; break; } - + initQuadtree(node); } } @@ -107,36 +107,36 @@ void initQuadtree(Quadtree *root) void addToQuadtree(Entity *e, Quadtree *root) { int index; - + root->addedTo = 1; - + if (root->node[0]) { index = getIndex(root, e->x, e->y, e->w, e->h); - + if (index != -1) { addToQuadtree(e, root->node[index]); return; } } - + if (root->numEnts == root->capacity) { resizeQTEntCapacity(root); } - + root->ents[root->numEnts++] = e; } static void resizeQTEntCapacity(Quadtree *root) { int n; - + n = root->capacity + QT_INITIAL_CAPACITY; - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Resizing QT node: %d -> %d", root->capacity, n); - + root->ents = resize(root->ents, sizeof(Entity*) * root->capacity, sizeof(Entity*) * n); root->capacity = n; } @@ -144,7 +144,7 @@ static void resizeQTEntCapacity(Quadtree *root) static int getIndex(Quadtree *root, int x, int y, int w, int h) { int index, verticalMidpoint, horizontalMidpoint, topQuadrant, bottomQuadrant; - + index = -1; verticalMidpoint = root->x + (root->w / 2); @@ -181,26 +181,26 @@ static int getIndex(Quadtree *root, int x, int y, int w, int h) void removeFromQuadtree(Entity *e, Quadtree *root) { int index; - + if (root->addedTo) { if (root->node[0]) { index = getIndex(root, e->x, e->y, e->w, e->h); - + if (index != -1) { removeFromQuadtree(e, root->node[index]); return; } } - + removeEntity(e, root); - + if (root->numEnts == 0) { root->addedTo = 0; - + if (root->node[0]) { root->addedTo = root->node[0]->addedTo || root->node[1]->addedTo || root->node[2]->addedTo || root->node[3]->addedTo; @@ -212,9 +212,9 @@ void removeFromQuadtree(Entity *e, Quadtree *root) static void removeEntity(Entity *e, Quadtree *root) { int i, n; - + n = root->numEnts; - + for (i = 0 ; i < root->capacity ; i++) { if (root->ents[i] == e) @@ -223,7 +223,7 @@ static void removeEntity(Entity *e, Quadtree *root) root->numEnts--; } } - + qsort(root->ents, n, sizeof(Entity*), candidatesComparator); } @@ -231,9 +231,9 @@ Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore) { cIndex = 0; memset(candidates, 0, sizeof(Entity*) * cCapacity); - + getAllEntsWithinNode(x, y, w, h, ignore, &world.quadtree); - + return candidates; } @@ -245,13 +245,13 @@ Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore) static void getAllEntsWithinNode(int x, int y, int w, int h, Entity *ignore, Quadtree *root) { int index, i; - + if (root->addedTo) { if (root->node[0]) { index = getIndex(root, x, y, w, h); - + if (index != -1) { getAllEntsWithinNode(x, y, w, h, ignore, root->node[index]); @@ -264,11 +264,11 @@ static void getAllEntsWithinNode(int x, int y, int w, int h, Entity *ignore, Qua } } } - + for (i = 0 ; i < root->numEnts ; i++) { candidates[cIndex++] = root->ents[i]; - + if (cIndex == cCapacity) { resizeCandidates(); @@ -280,11 +280,11 @@ static void getAllEntsWithinNode(int x, int y, int w, int h, Entity *ignore, Qua static void resizeCandidates(void) { int n; - + n = cCapacity + QT_INITIAL_CAPACITY; - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Resizing candidates: %d -> %d", cCapacity, n); - + candidates = resize(candidates, sizeof(Entity*) * cCapacity, sizeof(Entity*) * n); cCapacity = n; } @@ -292,11 +292,11 @@ static void resizeCandidates(void) void destroyQuadtree(void) { destroyQuadtreeNode(&world.quadtree); - + if (candidates) { free(candidates); - + candidates = NULL; } } @@ -304,19 +304,19 @@ void destroyQuadtree(void) static void destroyQuadtreeNode(Quadtree *root) { int i; - + free(root->ents); - + root->ents = NULL; - + if (root->node[0]) { for (i = 0 ; i < 4 ; i++) { destroyQuadtreeNode(root->node[i]); - + free(root->node[i]); - + root->node[i] = NULL; } } @@ -326,7 +326,7 @@ static int candidatesComparator(const void *a, const void *b) { Entity *e1 = *((Entity**)a); Entity *e2 = *((Entity**)b); - + if (!e1) { return 1; diff --git a/src/world/quadtree.h b/src/world/quadtree.h index d0c91f4..eea4627 100644 --- a/src/world/quadtree.h +++ b/src/world/quadtree.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/radar.c b/src/world/radar.c index d3f67e5..703f60b 100644 --- a/src/world/radar.c +++ b/src/world/radar.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -45,31 +45,31 @@ void initRadar(void) { SDL_Rect limits; int renderWidth, renderHeight; - + renderWidth = (app.config.winWidth / MAP_TILE_SIZE) + 1; renderHeight = (app.config.winHeight / MAP_TILE_SIZE) + 1; - + startSectionTransition(); - + memset(blips, 0, sizeof(Entity*) * MAX_BLIPS); memset(marker, 0, sizeof(Marker) * MAX_MARKERS); - + app.delegate.logic = &logic; app.delegate.draw = &draw; - + viewRect.x = (world.bob->x / MAP_TILE_SIZE) - (VIEW_SIZE_X / 2); viewRect.y = (world.bob->y / MAP_TILE_SIZE) - (VIEW_SIZE_Y / 2); viewRect.w = VIEW_SIZE_X; viewRect.h = VIEW_SIZE_Y; - + limits.x = world.map.bounds.x / MAP_TILE_SIZE; limits.y = world.map.bounds.y / MAP_TILE_SIZE; limits.w = (world.map.bounds.w / MAP_TILE_SIZE) - (VIEW_SIZE_X - renderWidth) - 1; limits.h = (world.map.bounds.h / MAP_TILE_SIZE) - (VIEW_SIZE_Y - renderHeight); - + viewRect.x = limit(viewRect.x, limits.x, limits.w); viewRect.y = limit(viewRect.y, limits.y, limits.h); - + if (viewRect.y > limits.h) { viewRect.y -= (viewRect.y - limits.h); @@ -81,32 +81,32 @@ void initRadar(void) background = getImageFromAtlas("gfx/radar/background.png"); arrow = getImageFromAtlas("gfx/radar/arrow.png"); - + /* top */ initMarker(0, app.config.winWidth / 2 - 275, app.config.winHeight / 2 - 275, 0, M_MIA); initMarker(1, app.config.winWidth / 2, app.config.winHeight / 2 - 275, 0, M_ITEM); initMarker(2, app.config.winWidth / 2 + 275, app.config.winHeight / 2 - 275, 0, M_ENEMY); - + /* bottom */ initMarker(3, app.config.winWidth / 2 - 275, app.config.winHeight / 2 + 275, 180, M_MIA); initMarker(4, app.config.winWidth / 2, app.config.winHeight / 2 + 275, 180, M_ITEM); initMarker(5, app.config.winWidth / 2 + 275, app.config.winHeight / 2 + 275, 180, M_ENEMY); - + /* left */ initMarker(6, app.config.winWidth / 2 - 450, app.config.winHeight / 2 - 200, 270, M_MIA); initMarker(7, app.config.winWidth / 2 - 450, app.config.winHeight / 2, 270, M_ITEM); initMarker(8, app.config.winWidth / 2 - 450, app.config.winHeight / 2 + 200, 270, M_ENEMY); - + /* right */ initMarker(9, app.config.winWidth / 2 + 450, app.config.winHeight / 2 - 200, 90, M_MIA); initMarker(10, app.config.winWidth / 2 + 450, app.config.winHeight / 2, 90, M_ITEM); initMarker(11, app.config.winWidth / 2 + 450, app.config.winHeight / 2 + 200, 90, M_ENEMY); - + initBlips(); - + offset.x = ((app.config.winWidth - (RADAR_TILE_SIZE * VIEW_SIZE_X)) / 2); offset.y = ((app.config.winHeight - (RADAR_TILE_SIZE * VIEW_SIZE_Y)) / 2); - + endSectionTransition(); } @@ -122,36 +122,36 @@ static void initBlips(void) { Entity *e; int i, x, y; - + i = 0; - + for (e = world.entityHead.next ; e != NULL ; e = e->next) { if (isValidBlip(e)) { x = (e->x / MAP_TILE_SIZE); y = (e->y / MAP_TILE_SIZE); - + if (y < viewRect.y) { enableMarker(e->type, M_MIA); } - + if (y > viewRect.y + viewRect.h) { enableMarker(e->type, M_MIA + (M_MAX)); } - + if (x < viewRect.x) { enableMarker(e->type, M_MIA + (M_MAX * 2)); } - + if (x > viewRect.x + viewRect.w) { enableMarker(e->type, M_MIA + (M_MAX * 3)); } - + if (i < MAX_BLIPS) { blips[i++] = e; @@ -169,21 +169,21 @@ static void enableMarker(int type, int i) case ET_TEEKA: marker[i].visible = 1; break; - + case ET_HEART: case ET_CELL: case ET_KEY: case ET_ITEM: marker[i + 1].visible = 1; break; - + case ET_ENEMY: case ET_BOSS: case ET_DESTRUCTABLE: case ET_ITEM_PAD: marker[i + 2].visible = 1; break; - + default: break; } @@ -193,14 +193,14 @@ static void logic(void) { int i; Marker *m; - + blinkTimer++; blinkTimer %= 60; - + for (i = 0 ; i < MAX_MARKERS ; i++) { m = &marker[i]; - + if (i / 3 % 2 == 0) { m->value += 0.1; @@ -209,7 +209,7 @@ static void logic(void) { m->value -= 0.1; } - + if (i < 6) { m->y += (float) sin(m->value); @@ -219,7 +219,7 @@ static void logic(void) m->x += (float) sin(m->value); } } - + if (isControl(CONTROL_MAP)) { pauseSound(0); @@ -233,17 +233,17 @@ static void draw(void) blitRectScaled(atlasTexture->texture, 0, 0, app.config.winWidth, app.config.winHeight, &background->rect, 0); drawMap(); - + drawEntities(); - + drawMarkers(); - + drawRect((app.config.winWidth / 2) - 230, app.config.winHeight - 58, 14, 14, 255, 255, 0, 255); drawText((app.config.winWidth / 2) - 200, app.config.winHeight - 65, 20, TA_LEFT, colors.yellow, app.strings[ST_MIAS]); - + drawRect((app.config.winWidth / 2) - 30, app.config.winHeight - 58, 14, 14, 0, 255, 255, 255); drawText((app.config.winWidth / 2), app.config.winHeight - 65, 20, TA_LEFT, colors.cyan, app.strings[ST_ITEMS]); - + drawRect((app.config.winWidth / 2) + 170, app.config.winHeight - 58, 14, 14, 255, 0, 0, 255); drawText((app.config.winWidth / 2) + 200, app.config.winHeight - 65, 20, TA_LEFT, colors.red, app.strings[ST_TARGETS]); } @@ -252,52 +252,52 @@ static void drawMap(void) { int x, y, mx, my, i; SDL_Color c; - + for (x = 0 ; x < viewRect.w ; x++) { for (y = 0 ; y < viewRect.h ; y++) { mx = viewRect.x + x; my = viewRect.y + y; - + drawRect(offset.x + (x * RADAR_TILE_SIZE), offset.y + (y * RADAR_TILE_SIZE), RADAR_TILE_SIZE - 1, RADAR_TILE_SIZE - 1, 0, 0, 0, 255); - + if (isWithinMap(mx, my)) { i = world.map.data[mx][my]; - + if (i > MAP_TILE_AIR && i < MAP_TILE_NON_SOLID) { getMapTileColor(i, &c); - + drawRect(offset.x + (x * RADAR_TILE_SIZE), offset.y + (y * RADAR_TILE_SIZE), RADAR_TILE_SIZE - 1, RADAR_TILE_SIZE - 1, c.r, c.g, c.b, 255); } } } } - + drawOutlineRect(offset.x, offset.y, viewRect.w * RADAR_TILE_SIZE, viewRect.h * RADAR_TILE_SIZE, 0, 128, 0, 255); } static void getMapTileColor(int i, SDL_Color *c) { c->r = c->g = c->b = 0; - + switch (i) { case MAP_TILE_WATER: c->b = 255; break; - + case MAP_TILE_SLIME: c->g = 255; break; - + case MAP_TILE_LAVA: c->g = 128; c->r = 255; break; - + default: if (i < MAP_TILE_NON_SOLID) { @@ -313,21 +313,21 @@ static void drawEntities(void) Entity *e; int i, x, y; SDL_Color c; - + for (i = 0 ; i < MAX_BLIPS ; i++) { e = blips[i]; - + if (e != NULL) { x = (e->x / MAP_TILE_SIZE); y = (e->y / MAP_TILE_SIZE); - + if (x >= viewRect.x && x < viewRect.x + viewRect.w && y >= viewRect.y && y < viewRect.y + viewRect.h) { x -= viewRect.x; y -= viewRect.y; - + getBlipColor(e, &c); if (blinkTimer < 30) @@ -342,7 +342,7 @@ static void drawEntities(void) static int isValidBlip(Entity *e) { Item *i; - + if (!(e->flags & (EF_GONE | EF_TELEPORTING))) { switch (e->type) @@ -356,37 +356,37 @@ static int isValidBlip(Entity *e) case ET_KEY: case ET_DESTRUCTABLE: return 1; - + case ET_ITEM: i = (Item*)e; return i->canBeCarried || i->canBePickedUp || i->isMissionTarget; - + case ET_ENEMY: return e->isMissionTarget || ((Unit*)e)->carriedItem != NULL || world.isEliminateAllEnemies; - + case ET_ITEM_PAD: return !e->active; - + default: return 0; } } - + return 0; } static void getBlipColor(Entity *e, SDL_Color *c) { Unit *u; - + c->r = c->g = c->b = 0; - + switch (e->type) { case ET_BOB: c->r = c->g = c->b = 255; break; - + case ET_ENEMY: u = (Unit*)e; if (u->carriedItem != NULL) @@ -399,19 +399,19 @@ static void getBlipColor(Entity *e, SDL_Color *c) c->r = 255; } break; - + case ET_BOSS: case ET_DESTRUCTABLE: case ET_ITEM_PAD: c->r = 255; break; - + case ET_TEEKA: case ET_MIA: c->r = c->g = 255; break; - + case ET_HEART: case ET_CELL: case ET_KEY: @@ -419,7 +419,7 @@ static void getBlipColor(Entity *e, SDL_Color *c) c->g = 168; c->b = 255; break; - + default: break; } @@ -428,7 +428,7 @@ static void getBlipColor(Entity *e, SDL_Color *c) static void drawMarkers(void) { int i; - + for (i = 0 ; i < MAX_MARKERS ; i++) { if (marker[i].visible) @@ -438,19 +438,19 @@ static void drawMarkers(void) case M_MIA: SDL_SetTextureColorMod(atlasTexture->texture, 255, 255, 0); break; - + case M_ITEM: SDL_SetTextureColorMod(atlasTexture->texture, 0, 192, 255); break; - + case M_ENEMY: SDL_SetTextureColorMod(atlasTexture->texture, 255, 0, 0); break; } - + blitRectRotated(atlasTexture->texture, marker[i].x, marker[i].y, &arrow->rect, marker[i].angle); } } - + SDL_SetTextureColorMod(atlasTexture->texture, 255, 255, 255); } diff --git a/src/world/radar.h b/src/world/radar.h index 556b32a..2a29561 100644 --- a/src/world/radar.h +++ b/src/world/radar.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/triggers.c b/src/world/triggers.c index aab7819..96b3147 100644 --- a/src/world/triggers.c +++ b/src/world/triggers.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -23,9 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void doLocationTriggers(void) { Trigger *t, *prev; - + prev = &world.triggerHead; - + for (t = world.triggerHead.next ; t != NULL ; t = t->next) { if (t->w > 0 && t->h > 0) @@ -38,7 +38,7 @@ void doLocationTriggers(void) { setGameplayMessage(MSG_GAMEPLAY, t->message); } - + if (t == world.triggerTail) { world.triggerTail = prev; @@ -49,7 +49,7 @@ void doLocationTriggers(void) t = prev; } } - + prev = t; } } @@ -57,9 +57,9 @@ void doLocationTriggers(void) void fireTriggers(char *name) { Trigger *t, *prev; - + prev = &world.triggerHead; - + for (t = world.triggerHead.next ; t != NULL ; t = t->next) { if (strcmp(t->name, name) == 0) @@ -70,7 +70,7 @@ void fireTriggers(char *name) { setGameplayMessage(MSG_GAMEPLAY, t->message); } - + if (t == world.triggerTail) { world.triggerTail = prev; @@ -80,7 +80,7 @@ void fireTriggers(char *name) free(t); t = prev; } - + prev = t; } } diff --git a/src/world/triggers.h b/src/world/triggers.h index c5bda8d..6a95a0e 100644 --- a/src/world/triggers.h +++ b/src/world/triggers.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/world.c b/src/world/world.c index b2cd0c7..a49a71a 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -62,39 +62,39 @@ static PointF observePos; void initWorld(void) { startSectionTransition(); - + loadWorld(game.worldId); - + world.currentStatus = getMissionStatus(game.worldId); - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "world.currentStatus = %d", world.currentStatus); - + background = getTexture(world.background); - + atlasTexture = getTexture("gfx/atlas/atlas.png"); - + missionFailed = getImageFromAtlas("gfx/main/missionFailed.png"); - + loadMusic(world.music); - + initQuadtree(&world.quadtree); - + initObjectives(); - + initParticles(); - + initHud(); - + initWeapons(); - + initEffects(); initItems(); initMap(); - + initEntities(); - + addKeysFromStash(); world.enemySpawnTimer = (FPS * rrnd(world.minEnemySpawnTime, world.maxEnemySpawnTime)); @@ -102,18 +102,18 @@ void initWorld(void) world.state = WS_START; observationIndex = 0; - + getWidget("resume", "gamePaused")->action = resume; getWidget("options", "gamePaused")->action = options; getWidget("stats", "gamePaused")->action = stats; getWidget("trophies", "gamePaused")->action = trophies; getWidget("quit", "gamePaused")->action = quit; - + getWidget("ok", "stats")->action = returnFromTrophyStats; getWidget("ok", "trophies")->action = returnFromTrophyStats; getWidget("ok", "gameQuit")->action = quitMission; getWidget("cancel", "gameQuit")->action = returnFromTrophyStats; - + getWidget("retry", "gameOver")->action = retry; getWidget("hub", "gameOver")->action = hub; getWidget("title", "gameOver")->action = title; @@ -127,19 +127,19 @@ void initWorld(void) else { world.bob->flags |= EF_GONE; - + playMusic(1); } - + game.stats[STAT_MISSIONS_PLAYED]++; - + app.delegate.logic = &logic; app.delegate.draw = &draw; - + app.restrictTrophyAlert = 1; - + endSectionTransition(); - + /* startMission(); world.bob->x = 17 * MAP_TILE_SIZE; @@ -152,45 +152,45 @@ static void logic(void) if (--world.betweenTimer <= 0) { world.betweenTimer = 0; - + world.saveDelay = limit(world.saveDelay - 1, 0, FPS); - + switch (world.state) { case WS_START: doWorldStart(); break; - + case WS_IN_PROGRESS: doWorldInProgress(); break; - + case WS_OBSERVING: doWorldObserving(); break; - + case WS_PAUSED: doWorldPaused(); break; - + case WS_COMPLETE: case WS_QUIT: doWorldComplete(); break; - + case WS_GAME_OVER: doGameOver(); break; - + case WS_GAME_COMPLETE: doGameComplete(); break; - + default: break; } } - + if (--world.mapAnimTimer < 0) { world.mapAnimTimer = 4; @@ -200,24 +200,24 @@ static void logic(void) static void draw(void) { clearScreen(); - + switch (world.state) { case WS_PAUSED: drawNormal(); drawMissionStatus(0); break; - + case WS_START: drawNormal(); drawMissionStatus(1); break; - + case WS_GAME_OVER: drawNormal(); drawGameOver(); break; - + default: if (world.betweenTimer == 0) { @@ -226,21 +226,21 @@ static void draw(void) } break; } - + switch (showing) { case SHOW_WIDGETS: drawInGameWidgets(); break; - + case SHOW_STATS: drawStats(); break; - + case SHOW_TROPHIES: drawTrophies(); break; - + case SHOW_QUIT: drawQuit(); break; @@ -250,28 +250,28 @@ static void draw(void) static void drawInGameWidgets(void) { drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128); - + SDL_SetRenderTarget(app.renderer, app.uiBuffer); - + drawWidgetFrame(); - + drawWidgets(); - + SDL_SetRenderTarget(app.renderer, app.backBuffer); } static void drawNormal(void) { blitScaled(background->texture, 0, 0, app.config.winWidth, app.config.winHeight, 0); - + drawEntities(PLANE_BACKGROUND); - + drawParticles(PLANE_BACKGROUND); - + drawMap(); - + drawEntities(PLANE_FOREGROUND); - + drawParticles(PLANE_FOREGROUND); } @@ -279,18 +279,18 @@ static void startMission(void) { Entity *self; SDL_Rect *r; - + self = (Entity*)world.bob; - + world.state = WS_IN_PROGRESS; world.betweenTimer = FPS / 2; - + r = &self->sprite[self->facing]->frames[self->spriteFrame]->rect; self->w = r->w; self->h = r->h; - + resetAtCheckpoint(); - + world.entityToTrack = self; self->flags &= ~EF_GONE; } @@ -298,15 +298,15 @@ static void startMission(void) static void doWorldStart(void) { float dist; - + if (world.entityToTrack != NULL) { dist = cameraChase(world.entityToTrack, 5); - + if ((dist <= world.entityToTrack->w && dist <= world.entityToTrack->h) || world.entityChaseTimer <= 0) { world.entityToTrack = getRandomObjectiveEntity(); - + world.entityChaseTimer = FPS * 5; } } @@ -318,13 +318,13 @@ static void doWorldStart(void) } world.entityChaseTimer = MAX(world.entityChaseTimer - 1, 0); - + doCommon(); - + if (isAcceptControl()) { clearControls(); - + startMission(); } } @@ -334,7 +334,7 @@ static void doWorldInProgress(void) cameraTrack(world.entityToTrack); doPlayer(); - + if (showing == SHOW_NONE) { doBob(); @@ -342,7 +342,7 @@ static void doWorldInProgress(void) doCommon(); doLocationTriggers(); - + world.time++; if (world.allObjectivesComplete && world.state != WS_COMPLETE) @@ -369,21 +369,21 @@ static void doWorldInProgress(void) stopMusic(); } } - + if (isControl(CONTROL_PAUSE)) { world.state = WS_PAUSED; pauseSound(1); clearControl(CONTROL_PAUSE); } - + if (isControl(CONTROL_MAP)) { pauseSound(1); initRadar(); clearControl(CONTROL_MAP); } - + if (app.keyboard[SDL_SCANCODE_ESCAPE]) { app.keyboard[SDL_SCANCODE_ESCAPE] = 0; @@ -391,7 +391,7 @@ static void doWorldInProgress(void) playSound(SND_MENU_BACK, 0); showing = SHOW_WIDGETS; } - + if (world.observationTimer > 0) { if (--world.observationTimer == FPS) @@ -415,25 +415,25 @@ static void doWorldInProgress(void) if (app.keyboard[SDL_SCANCODE_ESCAPE]) { playSound(SND_MENU_BACK, 0); - + returnFromTrophyStats(); } } else if (showing == SHOW_TROPHIES) { doTrophies(); - + if (app.keyboard[SDL_SCANCODE_ESCAPE]) { playSound(SND_MENU_BACK, 0); - + returnFromTrophyStats(); } } else if (showing == SHOW_QUIT) { handleWidgets(); - + if (app.keyboard[SDL_SCANCODE_ESCAPE]) { returnFromTrophyStats(); @@ -444,11 +444,11 @@ static void doWorldInProgress(void) static void handleWidgets(void) { doWidgets(); - + if (app.keyboard[SDL_SCANCODE_ESCAPE]) { playSound(SND_MENU_BACK, 0); - + resume(); } } @@ -457,12 +457,12 @@ static void doWorldObserving(void) { int tx, ty; float diffX, diffY; - + tx = world.entityToTrack->x - (app.config.winWidth / 2); ty = world.entityToTrack->y - (app.config.winHeight / 2); - + doEntitiesStatic(); - + diffX = abs(camera.x - tx) / 20; diffY = abs(camera.y - ty) / 20; @@ -488,10 +488,10 @@ static void doWorldObserving(void) { observePos.y += diffY; } - + camera.x = observePos.x; camera.y = observePos.y; - + clipCamera(); if (collision(observePos.x, observePos.y, MAP_TILE_SIZE, MAP_TILE_SIZE, tx, ty, MAP_TILE_SIZE, MAP_TILE_SIZE)) @@ -520,7 +520,7 @@ static void doWorldObserving(void) static void doWorldPaused(void) { animateSprites(); - + if (isControl(CONTROL_PAUSE)) { pauseSound(0); @@ -536,7 +536,7 @@ static void doWorldComplete(void) if (world.missionCompleteTimer <= 0 && world.saveDelay <= 0) { dropCarriedItems(); - + initPostMission(); } else if (world.missionCompleteTimer == FPS * 1.5) @@ -558,7 +558,7 @@ static void doGameComplete(void) if (--world.missionCompleteTimer <= 0) { dropCarriedItems(); - + initPostMission(); } else @@ -581,11 +581,11 @@ static void doGameOver(void) playMusic(0); showWidgetGroup("gameOver"); } - + world.gameOverTimer = MAX(-FPS * 5, world.gameOverTimer - 1); doCommon(); - + if (world.gameOverTimer <= -FPS * 3) { doWidgets(); @@ -655,7 +655,7 @@ static void spawnEnemies(void) world.numToSpawn = 3 + (rand() % 3); world.spawnInterval = 0; } - + return; } @@ -674,7 +674,7 @@ static void spawnEnemies(void) sprintf(name, "%s%s", world.enemyTypes[r], (rand() % 2 ? "Blob" : "EyeDroid")); u = (Unit*)createEntity(name); - + self = (Entity*)u; u->animate(); @@ -742,11 +742,11 @@ static int canAdd(Unit *u, int mx, int my) void observeActivation(Entity *e) { int i; - + if (!isOnScreen(e) && (!(e->flags & EF_NO_OBSERVE))) { e->flags |= EF_NO_OBSERVE; - + for (i = 0 ; i < MAX_ENTS_TO_OBSERVE ; i++) { if (world.entitiesToObserve[i] == NULL) @@ -760,7 +760,7 @@ void observeActivation(Entity *e) return; } } - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "Can't observe entity - out of array space"); exit(1); } @@ -769,24 +769,24 @@ void observeActivation(Entity *e) void drawGameOver(void) { int fadeAmount; - + fadeAmount = 0; - + if (world.gameOverTimer <= -FPS) { fadeAmount = MIN((world.gameOverTimer + FPS) * -1, 128); } - + drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, fadeAmount); - + if (world.gameOverTimer <= -FPS * 2) { blitRect(atlasTexture->texture, app.config.winWidth / 2, 240, &missionFailed->rect, 1); - + if (world.gameOverTimer <= -FPS * 3) { drawWidgetFrame(); - + drawWidgets(); } } @@ -795,23 +795,23 @@ void drawGameOver(void) void drawQuit(void) { SDL_Rect r; - + drawRect(0, 0, app.config.winWidth, app.config.winHeight, 0, 0, 0, 128); - + SDL_SetRenderTarget(app.renderer, app.uiBuffer); - + r.w = 650; r.h = 325; r.x = (UI_WIDTH / 2) - r.w / 2; r.y = (UI_HEIGHT / 2) - r.h / 2; - + drawRect(r.x, r.y, r.w, r.h, 0, 0, 0, 192); - + drawOutlineRect(r.x, r.y, r.w, r.h, 200, 200, 200, 255); - + app.textWidth = (r.w - 100); drawText(UI_WIDTH / 2, r.y + 10, 26, TA_CENTER, colors.white, app.strings[ST_QUIT_HUB]); - + if (world.missionType == MT_TRAINING) { drawText(UI_WIDTH / 2, r.y + 65, 26, TA_CENTER, colors.white, app.strings[ST_QUIT_TUTORIAL]); @@ -828,21 +828,21 @@ void drawQuit(void) { drawText(UI_WIDTH / 2, r.y + 65, 26, TA_CENTER, colors.white, app.strings[ST_QUIT_LOSE]); } - + app.textWidth = 0; - + drawWidgets(); - + SDL_SetRenderTarget(app.renderer, app.backBuffer); } void exitRadar(void) { startSectionTransition(); - + app.delegate.logic = &logic; app.delegate.draw = &draw; - + endSectionTransition(); } @@ -905,7 +905,7 @@ void quitMission(void) stopMusic(); world.state = WS_QUIT; world.missionCompleteTimer = (FPS * 1.5) + 1; - + if (world.missionType == MT_TRAINING) { autoCompleteMission(); @@ -916,7 +916,7 @@ static void returnFromOptions(void) { app.delegate.logic = &logic; app.delegate.draw = &draw; - + returnFromTrophyStats(); } @@ -924,12 +924,12 @@ void autoCompleteMission(void) { Objective *o; Entity *e; - + for (o = world.objectiveHead.next ; o != NULL ; o = o->next) { o->currentValue = o->targetValue; } - + for (e = world.entityHead.next ; e != NULL ; e = e->next) { switch (e->type) @@ -938,7 +938,7 @@ void autoCompleteMission(void) e->alive = ALIVE_DEAD; game.stats[STAT_MIAS_RESCUED]++; break; - + case ET_KEY: if (!(e->flags & EF_GONE)) { @@ -946,12 +946,12 @@ void autoCompleteMission(void) game.stats[STAT_KEYS_FOUND]++; } break; - + default: break; } } - + world.state = WS_COMPLETE; } diff --git a/src/world/world.h b/src/world/world.h index 504894f..0b55b57 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/worldLoader.c b/src/world/worldLoader.c index 06384e5..ee43b91 100644 --- a/src/world/worldLoader.c +++ b/src/world/worldLoader.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -30,16 +30,16 @@ void loadWorld(char *id) { cJSON *root; char *text, *filename, enemyTypes[MAX_DESCRIPTION_LENGTH]; - + memset(&world, 0, sizeof(World)); - + world.entityTail = &world.entityHead; world.triggerTail = &world.triggerHead; world.objectiveTail = &world.objectiveHead; world.particleTail = &world.particleHead; - + filename = buildFormattedString("%s/%d/%s.json", app.saveDir, game.saveSlot, id); - + if (!game.isComplete && fileExists(filename)) { text = readFile(filename); @@ -47,12 +47,12 @@ void loadWorld(char *id) else { sprintf(filename, "data/maps/%s.json", id); - + text = readFile(filename); } root = cJSON_Parse(text); - + STRNCPY(world.id, cJSON_GetObjectItem(root, "id")->valuestring, MAX_NAME_LENGTH); STRNCPY(world.name, cJSON_GetObjectItem(root, "name")->valuestring, MAX_NAME_LENGTH); world.minEnemySpawnTime = cJSON_GetObjectItem(root, "minEnemySpawnTime")->valueint; @@ -61,11 +61,11 @@ void loadWorld(char *id) STRNCPY(world.tileset, cJSON_GetObjectItem(root, "tileset")->valuestring, MAX_NAME_LENGTH); STRNCPY(world.background, cJSON_GetObjectItem(root, "background")->valuestring, MAX_FILENAME_LENGTH); world.entityCounter = cJSON_GetObjectItem(root, "entityCounter")->valueint; - + world.missionType = strcmp(world.id, "beachApproach") == 0 ? MT_TRAINING : MT_NORMAL; world.missionType = strncmp(world.id, "outpost", 7) == 0 ? MT_OUTPOST : world.missionType; world.missionType = strncmp(world.id, "boss", 4) == 0 ? MT_BOSS : world.missionType; - + if (!(game.plus & PLUS_RANDOM)) { loadEnemyTypes(cJSON_GetObjectItem(root, "enemyTypes")->valuestring); @@ -75,19 +75,19 @@ void loadWorld(char *id) STRNCPY(enemyTypes, "Pistol|Grenade|MachineGun|Shotgun|Laser|SpreadGun|Plasma", MAX_DESCRIPTION_LENGTH); loadEnemyTypes(enemyTypes); } - + loadTriggers(cJSON_GetObjectItem(root, "triggers")); - + loadBob(cJSON_GetObjectItem(root, "bob")); - + loadEntities(cJSON_GetObjectItem(root, "entities")); - + loadObjectives(cJSON_GetObjectItem(root, "objectives")); - + cJSON_Delete(root); - + free(text); - + free(filename); } @@ -95,7 +95,7 @@ static void loadEnemyTypes(char *enemyTypes) { int i; char *enemyType; - + world.numEnemyTypes = 1; for (i = 0 ; i < strlen(enemyTypes) ; i++) @@ -114,7 +114,7 @@ static void loadEnemyTypes(char *enemyTypes) { world.enemyTypes[i] = malloc(strlen(enemyType) + 1); strcpy(world.enemyTypes[i], enemyType); - + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "world.entityTypes[%d] = %s", i, enemyType); enemyType = strtok(NULL, "|"); @@ -127,14 +127,14 @@ static void loadTriggers(cJSON *root) { cJSON *node; Trigger *t; - + for (node = root->child ; node != NULL ; node = node->next) { t = malloc(sizeof(Trigger)); memset(t, 0, sizeof(Trigger)); world.triggerTail->next = t; world.triggerTail = t; - + STRNCPY(t->name, cJSON_GetObjectItem(node, "name")->valuestring, MAX_NAME_LENGTH); STRNCPY(t->targetNames, cJSON_GetObjectItem(node, "targetNames")->valuestring, MAX_DESCRIPTION_LENGTH); STRNCPY(t->message, _(cJSON_GetObjectItem(node, "message")->valuestring), MAX_DESCRIPTION_LENGTH); @@ -142,7 +142,7 @@ static void loadTriggers(cJSON *root) t->y = cJSON_GetObjectItem(node, "y")->valueint; t->w = cJSON_GetObjectItem(node, "w")->valueint; t->h = cJSON_GetObjectItem(node, "h")->valueint; - + if (game.plus & PLUS_MIRROR) { t->x = MAP_PIXEL_WIDTH - t->x; @@ -154,13 +154,13 @@ static void loadTriggers(cJSON *root) static void loadBob(cJSON *root) { world.bob = (Bob*)createEntity("Bob"); - + self = (Entity*)world.bob; - + world.bob->load(root); - + world.bob->init(); - + world.bob->animate(); if (game.plus != PLUS_NONE) @@ -173,32 +173,32 @@ static void loadBob(cJSON *root) static void loadEntities(cJSON *root) { cJSON *node; - + for (node = root->child ; node != NULL ; node = node->next) { self = createEntity(cJSON_GetObjectItem(node, "type")->valuestring); - + if (cJSON_GetObjectItem(node, "name")) { STRNCPY(self->name, cJSON_GetObjectItem(node, "name")->valuestring, MAX_NAME_LENGTH); } - + self->x = cJSON_GetObjectItem(node, "x")->valueint; self->y = cJSON_GetObjectItem(node, "y")->valueint; - + self->load(node); - + if (game.plus & PLUS_MIRROR) { self->x = MAP_PIXEL_WIDTH - self->x; - + self->flags |= EF_MIRROR; } - + self->init(); - + self->animate(); - + if (self->type == ET_ENEMY && dev.cheatNoEnemies) { self->alive = ALIVE_DEAD; @@ -211,16 +211,16 @@ static void loadObjectives(cJSON *root) Objective *o; cJSON *node; int hasEliminateAll; - + hasEliminateAll = 0; - + for (node = root->child ; node != NULL ; node = node->next) { o = malloc(sizeof(Objective)); memset(o, 0, sizeof(Objective)); world.objectiveTail->next = o; world.objectiveTail = o; - + STRNCPY(o->id, cJSON_GetObjectItem(node, "id")->valuestring, MAX_NAME_LENGTH); STRNCPY(o->targetName, cJSON_GetObjectItem(node, "targetName")->valuestring, MAX_NAME_LENGTH); STRNCPY(o->description, cJSON_GetObjectItem(node, "description")->valuestring, MAX_DESCRIPTION_LENGTH); @@ -228,17 +228,17 @@ static void loadObjectives(cJSON *root) o->targetValue = cJSON_GetObjectItem(node, "targetValue")->valueint; o->currentValue = cJSON_GetObjectItem(node, "currentValue")->valueint; o->required = cJSON_GetObjectItem(node, "required")->valueint; - + if (strcmp(o->targetName, "ENEMY") == 0) { hasEliminateAll = 1; } - + if (game.plus != PLUS_NONE) { o->required = 1; } - + world.numObjectives++; } @@ -248,14 +248,14 @@ static void loadObjectives(cJSON *root) memset(o, 0, sizeof(Objective)); world.objectiveTail->next = o; world.objectiveTail = o; - + STRNCPY(o->id, "O99", MAX_NAME_LENGTH); STRNCPY(o->targetName, "ENEMY", MAX_NAME_LENGTH); STRNCPY(o->description, _("Defeat enemies"), MAX_DESCRIPTION_LENGTH); o->required = 1; - + world.minEnemySpawnTime = world.maxEnemySpawnTime = 0; - + world.numObjectives++; } } diff --git a/src/world/worldLoader.h b/src/world/worldLoader.h index d716095..083753b 100644 --- a/src/world/worldLoader.h +++ b/src/world/worldLoader.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/world/worldSaver.c b/src/world/worldSaver.c index 1ec2d5e..edd7aa5 100644 --- a/src/world/worldSaver.c +++ b/src/world/worldSaver.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -47,13 +47,13 @@ void saveWorld(void) cJSON_AddNumberToObject(root, "entityCounter", world.entityCounter); saveEnemyTypes(root); - + saveTriggers(root); - + saveBob(root); - + saveEntities(root); - + saveObjectives(root); out = cJSON_Print(root); @@ -66,7 +66,7 @@ void saveWorld(void) cJSON_Delete(root); free(out); - + free(filename); } @@ -161,11 +161,11 @@ static int canPersistEntity(void) case ET_DECORATION: case ET_CONSUMABLE: return 0; - + default: return self->health > 0 && self->alive == ALIVE_ALIVE; } - + return 0; } diff --git a/src/world/worldSaver.h b/src/world/worldSaver.h index 52d51b6..c00a3a2 100644 --- a/src/world/worldSaver.h +++ b/src/world/worldSaver.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018 Parallel Realities +Copyright (C) 2018-2019 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License