Format with clang.
This commit is contained in:
parent
5e82c957cd
commit
118b99ccf6
|
@ -0,0 +1,230 @@
|
|||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: Google
|
||||
AccessModifierOffset: -1
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveMacros: Consecutive
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveBitFields: None
|
||||
AlignConsecutiveDeclarations: Consecutive
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: true
|
||||
BreakBeforeBraces: Allman
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 1024
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
QualifierAlignment: Leave
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: true
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
PackConstructorInitializers: NextLine
|
||||
BasedOnStyle: ''
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: '^<ext/.*\.h>'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^<.*'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*common.h'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: 'common.h'
|
||||
IncludeIsMainSourceRegex: 'common.h'
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseLabels: true
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentRequires: false
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
LambdaBodyIndentation: Signature
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Never
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 1
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 200
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PointerAlignment: Left
|
||||
PPIndentWidth: -1
|
||||
RawStringFormats:
|
||||
- Language: Cpp
|
||||
Delimiters:
|
||||
- cc
|
||||
- CC
|
||||
- cpp
|
||||
- Cpp
|
||||
- CPP
|
||||
- 'c++'
|
||||
- 'C++'
|
||||
CanonicalDelimiter: ''
|
||||
BasedOnStyle: google
|
||||
- Language: TextProto
|
||||
Delimiters:
|
||||
- pb
|
||||
- PB
|
||||
- proto
|
||||
- PROTO
|
||||
EnclosingFunctions:
|
||||
- EqualsProto
|
||||
- EquivToProto
|
||||
- PARSE_PARTIAL_TEXT_PROTO
|
||||
- PARSE_TEST_PROTO
|
||||
- PARSE_TEXT_PROTO
|
||||
- ParseTextOrDie
|
||||
- ParseTextProtoOrDie
|
||||
- ParseTestProto
|
||||
- ParsePartialTestProto
|
||||
CanonicalDelimiter: pb
|
||||
BasedOnStyle: google
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: true
|
||||
RemoveBracesLLVM: false
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SortIncludes: CaseInsensitive
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterOverloadedOperator: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: Never
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
Standard: Auto
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 4
|
||||
UseCRLF: false
|
||||
UseTab: Always
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
- NS_SWIFT_NAME
|
||||
- CF_SWIFT_NAME
|
||||
...
|
||||
|
105
src/battle/ai.c
105
src/battle/ai.c
|
@ -19,64 +19,65 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "ai.h"
|
||||
#include "../battle/mine.h"
|
||||
#include "../system/util.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../battle/quadtree.h"
|
||||
|
||||
#include "../battle/bullets.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../battle/hud.h"
|
||||
#include "../battle/mine.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../system/util.h"
|
||||
#include "ai.h"
|
||||
|
||||
#define AI_EVADE 0
|
||||
#define AI_FALLBACK 1
|
||||
#define AI_HUNT 2
|
||||
#define TURN_SPEED 4
|
||||
#define TURN_THRESHOLD 2
|
||||
#define AI_EVADE 0
|
||||
#define AI_FALLBACK 1
|
||||
#define AI_HUNT 2
|
||||
#define TURN_SPEED 4
|
||||
#define TURN_THRESHOLD 2
|
||||
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Dev dev;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Dev dev;
|
||||
extern Entity *player;
|
||||
extern Entity *self;
|
||||
|
||||
static void faceTarget(Entity *e);
|
||||
static int isInFOV(Entity *e, int fov);
|
||||
static int isInFOV(Entity *e, int fov);
|
||||
static void preAttack(void);
|
||||
static void huntTarget(void);
|
||||
static void huntAndAttackTarget(void);
|
||||
static void moveToTargetLocation(void);
|
||||
static void nextAction(void);
|
||||
static void findTarget(void);
|
||||
static int hasClearShot(void);
|
||||
static int hasClearShot(void);
|
||||
static void fallback(void);
|
||||
static void moveToPlayer(void);
|
||||
static int canAttack(Entity *e);
|
||||
static int selectWeapon(int type);
|
||||
static int nearJumpgate(void);
|
||||
static int canAttack(Entity *e);
|
||||
static int selectWeapon(int type);
|
||||
static int nearJumpgate(void);
|
||||
static void moveToJumpgate(void);
|
||||
static int nearEnemies(void);
|
||||
static int nearItems(void);
|
||||
static int nearMines(void);
|
||||
static int nearEnemies(void);
|
||||
static int nearItems(void);
|
||||
static int nearMines(void);
|
||||
static void moveToItem(void);
|
||||
static int nearTowableCraft(void);
|
||||
static int nearTowableCraft(void);
|
||||
static void moveToTowableCraft(void);
|
||||
static int lookForPlayer(void);
|
||||
static int lookForLeader(void);
|
||||
static int lookForPlayer(void);
|
||||
static int lookForLeader(void);
|
||||
static void fleeEnemies(void);
|
||||
static int isRetreating(void);
|
||||
static int getActionChance(int type);
|
||||
static int isRetreating(void);
|
||||
static int getActionChance(int type);
|
||||
static void doFighterAI(void);
|
||||
static void doGunAI(void);
|
||||
static void moveToLeader(void);
|
||||
static void wander(void);
|
||||
static void doWander(void);
|
||||
static int selectWeaponForTarget(Entity *e);
|
||||
static int selectWeaponForTarget(Entity *e);
|
||||
static void deployMine(void);
|
||||
static int isSurrendering(void);
|
||||
static int isSurrendering(void);
|
||||
static void doSurrender(void);
|
||||
static void fleeWithinBattleArea(int x, int y, int numEnemies);
|
||||
static int evadeNonKillTargets(void);
|
||||
static int evadeNonKillTargets(void);
|
||||
|
||||
void doAI(void)
|
||||
{
|
||||
|
@ -151,7 +152,7 @@ void doAI(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if ((self->aiFlags & (AIF_FOLLOWS_PLAYER|AIF_MOVES_TO_PLAYER)) && lookForPlayer())
|
||||
if ((self->aiFlags & (AIF_FOLLOWS_PLAYER | AIF_MOVES_TO_PLAYER)) && lookForPlayer())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -340,8 +341,8 @@ static void huntAndAttackTarget(void)
|
|||
|
||||
static void findTarget(void)
|
||||
{
|
||||
int i;
|
||||
Entity *e, **candidates;
|
||||
int i;
|
||||
Entity *e, **candidates;
|
||||
unsigned int dist, closest;
|
||||
|
||||
dist = closest = (battle.isEpic || (self->aiFlags & AIF_UNLIMITED_RANGE)) ? MAX_TARGET_RANGE : SCREEN_WIDTH;
|
||||
|
@ -350,7 +351,7 @@ static void findTarget(void)
|
|||
|
||||
self->target = NULL;
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if (canAttack(e) && selectWeaponForTarget(e))
|
||||
{
|
||||
|
@ -437,7 +438,7 @@ static int selectWeapon(int type)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < MAX_FIGHTER_GUNS ; i++)
|
||||
for (i = 0; i < MAX_FIGHTER_GUNS; i++)
|
||||
{
|
||||
if (self->guns[i].type == type)
|
||||
{
|
||||
|
@ -481,14 +482,14 @@ static int isInFOV(Entity *e, int fov)
|
|||
|
||||
static int hasClearShot(void)
|
||||
{
|
||||
int dist;
|
||||
int dist;
|
||||
Entity *e;
|
||||
|
||||
if (isInFOV(self->target, 4))
|
||||
{
|
||||
dist = getDistance(self->x, self->y, self->target->x, self->target->y);
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (self->owner != NULL && self->owner == e->owner)
|
||||
{
|
||||
|
@ -523,7 +524,7 @@ static void preAttack(void)
|
|||
{
|
||||
fireGuns(self);
|
||||
}
|
||||
else if (self->missiles && (!(self->target->flags & (EF_NO_KILL|EF_MUST_DISABLE|EF_FRIENDLY_HEALTH_BAR))) && getDistance(self->x, self->y, self->target->x, self->target->y) >= 350)
|
||||
else if (self->missiles && (!(self->target->flags & (EF_NO_KILL | EF_MUST_DISABLE | EF_FRIENDLY_HEALTH_BAR))) && getDistance(self->x, self->y, self->target->x, self->target->y) >= 350)
|
||||
{
|
||||
fireMissile(self);
|
||||
|
||||
|
@ -675,7 +676,7 @@ static void doSurrender(void)
|
|||
|
||||
static int nearEnemies(void)
|
||||
{
|
||||
int i, numEnemies, x, y;
|
||||
int i, numEnemies, x, y;
|
||||
Entity *e, **candidates;
|
||||
|
||||
candidates = getAllEntsInRadius(self->x, self->y, SCREEN_WIDTH, self);
|
||||
|
@ -685,7 +686,7 @@ static int nearEnemies(void)
|
|||
|
||||
numEnemies = 0;
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if ((e->flags & EF_TAKES_DAMAGE) && e->side != SIDE_NONE && e->side != self->side && !(e->flags & EF_DISABLED))
|
||||
{
|
||||
|
@ -715,7 +716,7 @@ static int nearEnemies(void)
|
|||
|
||||
static int evadeNonKillTargets(void)
|
||||
{
|
||||
int i, numEnemies, x, y;
|
||||
int i, numEnemies, x, y;
|
||||
Entity *e, **candidates;
|
||||
|
||||
candidates = getAllEntsInRadius(self->x, self->y, SCREEN_WIDTH, self);
|
||||
|
@ -725,7 +726,7 @@ static int evadeNonKillTargets(void)
|
|||
|
||||
numEnemies = 0;
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if ((e->flags & EF_TAKES_DAMAGE) && e->side != SIDE_NONE && e->side != self->side && (!(e->flags & EF_DISABLED)))
|
||||
{
|
||||
|
@ -806,7 +807,7 @@ static void deployMine(void)
|
|||
|
||||
static int nearMines(void)
|
||||
{
|
||||
int i, numMines, x, y;
|
||||
int i, numMines, x, y;
|
||||
Entity *e, **candidates;
|
||||
|
||||
candidates = getAllEntsInRadius(self->x, self->y, SCREEN_HEIGHT, self);
|
||||
|
@ -815,7 +816,7 @@ static int nearMines(void)
|
|||
|
||||
numMines = 0;
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if (e->side != self->side && e->type == ET_MINE && getDistance(e->x, e->y, self->x, self->y) <= SCREEN_HEIGHT)
|
||||
{
|
||||
|
@ -913,8 +914,8 @@ static void moveToJumpgate(void)
|
|||
|
||||
static int nearItems(void)
|
||||
{
|
||||
int i;
|
||||
long closest, distance;
|
||||
int i;
|
||||
long closest, distance;
|
||||
Entity *e, **candidates;
|
||||
|
||||
closest = MAX_TARGET_RANGE;
|
||||
|
@ -923,7 +924,7 @@ static int nearItems(void)
|
|||
|
||||
self->target = NULL;
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if (e->type == ET_ITEM)
|
||||
{
|
||||
|
@ -961,8 +962,8 @@ static void moveToItem(void)
|
|||
|
||||
static int nearTowableCraft(void)
|
||||
{
|
||||
int i;
|
||||
long closest, dist;
|
||||
int i;
|
||||
long closest, dist;
|
||||
Entity *e, **candidates;
|
||||
|
||||
dist = closest = (battle.isEpic || (self->aiFlags & AIF_UNLIMITED_RANGE)) ? MAX_TARGET_RANGE : 2000;
|
||||
|
@ -971,9 +972,9 @@ static int nearTowableCraft(void)
|
|||
|
||||
self->target = NULL;
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if (!e->owner && (e->flags & (EF_DISABLED|EF_MISSION_TARGET)) == (EF_DISABLED|EF_MISSION_TARGET) && (e->flags & EF_ROPED_ATTACHED) == 0)
|
||||
if (!e->owner && (e->flags & (EF_DISABLED | EF_MISSION_TARGET)) == (EF_DISABLED | EF_MISSION_TARGET) && (e->flags & EF_ROPED_ATTACHED) == 0)
|
||||
{
|
||||
dist = getDistance(self->x, self->y, e->x, e->y);
|
||||
|
||||
|
@ -1018,13 +1019,13 @@ static int lookForPlayer(void)
|
|||
|
||||
static int lookForLeader(void)
|
||||
{
|
||||
long closest, distance;
|
||||
long closest, distance;
|
||||
Entity *e;
|
||||
|
||||
self->leader = NULL;
|
||||
closest = 0;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->active && e->flags & EF_AI_LEADER && e->side == self->side)
|
||||
{
|
||||
|
|
|
@ -19,49 +19,50 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "battle.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../game/credits.h"
|
||||
#include "../battle/locations.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../galaxy/mission.h"
|
||||
|
||||
#include "../battle/bullets.h"
|
||||
#include "../galaxy/galacticMap.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../battle/starfield.h"
|
||||
#include "../battle/player.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../battle/messageBox.h"
|
||||
#include "../battle/spawners.h"
|
||||
#include "../battle/waypoints.h"
|
||||
#include "../battle/radar.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../challenges/challenges.h"
|
||||
#include "../challenges/challengeHome.h"
|
||||
#include "../system/modalDialog.h"
|
||||
#include "../game/options.h"
|
||||
#include "../battle/hud.h"
|
||||
#include "../battle/missionInfo.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/input.h"
|
||||
#include "../game/stats.h"
|
||||
#include "../battle/debris.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "../battle/entities.h"
|
||||
#include "../battle/hud.h"
|
||||
#include "../battle/locations.h"
|
||||
#include "../battle/messageBox.h"
|
||||
#include "../battle/missionInfo.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/player.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../battle/radar.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../battle/spawners.h"
|
||||
#include "../battle/starfield.h"
|
||||
#include "../battle/waypoints.h"
|
||||
#include "../challenges/challengeHome.h"
|
||||
#include "../challenges/challenges.h"
|
||||
#include "../galaxy/galacticMap.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../game/credits.h"
|
||||
#include "../game/options.h"
|
||||
#include "../game/stats.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/input.h"
|
||||
#include "../system/modalDialog.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "battle.h"
|
||||
|
||||
#define SHOW_BATTLE 0
|
||||
#define SHOW_MENU 1
|
||||
#define SHOW_OBJECTIVES 2
|
||||
#define SHOW_OPTIONS 3
|
||||
#define SHOW_BATTLE 0
|
||||
#define SHOW_MENU 1
|
||||
#define SHOW_OBJECTIVES 2
|
||||
#define SHOW_OPTIONS 3
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Dev dev;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Dev dev;
|
||||
extern Entity *player;
|
||||
extern Game game;
|
||||
extern Game game;
|
||||
|
||||
static void logic(void);
|
||||
static void draw(void);
|
||||
|
@ -82,7 +83,7 @@ static void checkSuspicionLevel(void);
|
|||
static void doTorelliFireStorm(void);
|
||||
static void endCampaign(void);
|
||||
|
||||
static int show;
|
||||
static int show;
|
||||
static float ssx, ssy;
|
||||
|
||||
void initBattle(void)
|
||||
|
@ -476,7 +477,7 @@ static void postBattle(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < STAT_MAX ; i++)
|
||||
for (i = 0; i < STAT_MAX; i++)
|
||||
{
|
||||
if (i != STAT_TIME && i != STAT_EPIC_KILL_STREAK)
|
||||
{
|
||||
|
@ -528,13 +529,13 @@ static void endCampaign(void)
|
|||
|
||||
void destroyBattle(void)
|
||||
{
|
||||
Entity *ent;
|
||||
Bullet *b;
|
||||
Debris *d;
|
||||
Effect *e;
|
||||
Entity *ent;
|
||||
Bullet *b;
|
||||
Debris *d;
|
||||
Effect *e;
|
||||
Objective *o;
|
||||
Location *l;
|
||||
Spawner *s;
|
||||
Location *l;
|
||||
Spawner *s;
|
||||
|
||||
while (battle.entityHead.next)
|
||||
{
|
||||
|
|
|
@ -19,26 +19,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "bullets.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/util.h"
|
||||
|
||||
#include "../battle/effects.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/util.h"
|
||||
#include "bullets.h"
|
||||
|
||||
#define INITIAL_BULLET_DRAW_CAPACITY 32
|
||||
#define MISSILE_LIFE (FPS * 30)
|
||||
#define TURN_SPEED 2
|
||||
#define TURN_THRESHOLD 3
|
||||
#define INITIAL_BULLET_DRAW_CAPACITY 32
|
||||
#define MISSILE_LIFE (FPS * 30)
|
||||
#define TURN_SPEED 2
|
||||
#define TURN_THRESHOLD 3
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Entity *player;
|
||||
|
||||
static void huntTarget(Bullet *b);
|
||||
|
@ -47,23 +48,23 @@ static void resizeDrawList(void);
|
|||
static void selectNewTarget(Bullet *b);
|
||||
static void doBulletHitEffect(Bullet *b);
|
||||
|
||||
static Bullet bulletDef[BT_MAX];
|
||||
static Bullet bulletDef[BT_MAX];
|
||||
static Bullet **bulletsToDraw;
|
||||
static int drawCapacity;
|
||||
static int drawCapacity;
|
||||
|
||||
void initBullets(void)
|
||||
{
|
||||
drawCapacity = INITIAL_BULLET_DRAW_CAPACITY;
|
||||
|
||||
bulletsToDraw = malloc(sizeof(Bullet*) * drawCapacity);
|
||||
memset(bulletsToDraw, 0, sizeof(Bullet*) * drawCapacity);
|
||||
bulletsToDraw = malloc(sizeof(Bullet *) * drawCapacity);
|
||||
memset(bulletsToDraw, 0, sizeof(Bullet *) * drawCapacity);
|
||||
}
|
||||
|
||||
void initBulletDefs(void)
|
||||
{
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
int type;
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
int type;
|
||||
Bullet *def;
|
||||
|
||||
memset(&bulletDef, 0, sizeof(Bullet) * BT_MAX);
|
||||
|
@ -72,7 +73,7 @@ void initBulletDefs(void)
|
|||
|
||||
root = cJSON_Parse(text);
|
||||
|
||||
for (node = root->child ; node != NULL ; node = node->next)
|
||||
for (node = root->child; node != NULL; node = node->next)
|
||||
{
|
||||
type = lookup(cJSON_GetObjectItem(node, "type")->valuestring);
|
||||
|
||||
|
@ -93,15 +94,15 @@ void initBulletDefs(void)
|
|||
|
||||
void doBullets(void)
|
||||
{
|
||||
int i = 0;
|
||||
int i = 0;
|
||||
Bullet *b;
|
||||
Bullet *prev = &battle.bulletHead;
|
||||
|
||||
battle.incomingMissile = 0;
|
||||
|
||||
memset(bulletsToDraw, 0, sizeof(Bullet*) * drawCapacity);
|
||||
memset(bulletsToDraw, 0, sizeof(Bullet *) * drawCapacity);
|
||||
|
||||
for (b = battle.bulletHead.next ; b != NULL ; b = b->next)
|
||||
for (b = battle.bulletHead.next; b != NULL; b = b->next)
|
||||
{
|
||||
b->x += b->dx;
|
||||
b->y += b->dy;
|
||||
|
@ -163,7 +164,7 @@ static void resizeDrawList(void)
|
|||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Resizing bullet draw capacity: %d -> %d", drawCapacity, n);
|
||||
|
||||
bulletsToDraw = resize(bulletsToDraw, sizeof(Bullet*) * drawCapacity, sizeof(Bullet*) * n);
|
||||
bulletsToDraw = resize(bulletsToDraw, sizeof(Bullet *) * drawCapacity, sizeof(Bullet *) * n);
|
||||
|
||||
drawCapacity = n;
|
||||
}
|
||||
|
@ -171,11 +172,11 @@ static void resizeDrawList(void)
|
|||
static void checkCollisions(Bullet *b)
|
||||
{
|
||||
Entity *e, **candidates;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
candidates = getAllEntsWithin(b->x - (b->w / 2), b->y - (b->h / 2), b->w, b->h, NULL);
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if (e->flags & EF_TAKES_DAMAGE)
|
||||
{
|
||||
|
@ -203,7 +204,7 @@ static void checkCollisions(Bullet *b)
|
|||
|
||||
if (battle.hasSuspicionLevel)
|
||||
{
|
||||
if (e->aiFlags & (AIF_AVOIDS_COMBAT|AIF_DEFENSIVE))
|
||||
if (e->aiFlags & (AIF_AVOIDS_COMBAT | AIF_DEFENSIVE))
|
||||
{
|
||||
battle.suspicionLevel -= (MAX_SUSPICION_LEVEL * 0.1);
|
||||
}
|
||||
|
@ -310,12 +311,12 @@ static void doBulletHitEffect(Bullet *b)
|
|||
|
||||
void drawBullets(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Bullet *b;
|
||||
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
|
||||
for (i = 0, b = bulletsToDraw[i] ; b != NULL ; b = bulletsToDraw[++i])
|
||||
for (i = 0, b = bulletsToDraw[i]; b != NULL; b = bulletsToDraw[++i])
|
||||
{
|
||||
blitRotated(b->texture, b->x - battle.camera.x, b->y - battle.camera.y, b->angle);
|
||||
}
|
||||
|
@ -356,7 +357,7 @@ static void faceTarget(Bullet *b)
|
|||
|
||||
static void applyMissileThrust(Bullet *b)
|
||||
{
|
||||
int maxSpeed;
|
||||
int maxSpeed;
|
||||
float v, thrust;
|
||||
|
||||
b->dx += sin(TO_RAIDANS(b->angle));
|
||||
|
@ -397,7 +398,7 @@ static void huntTarget(Bullet *b)
|
|||
|
||||
static void selectNewTarget(Bullet *b)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Entity *e, **candidates;
|
||||
|
||||
if (app.gameplay.missileReTarget)
|
||||
|
@ -406,7 +407,7 @@ static void selectNewTarget(Bullet *b)
|
|||
|
||||
candidates = getAllEntsInRadius(b->x, b->y, SCREEN_HEIGHT, NULL);
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if (e->type == ET_FIGHTER && e->side != b->owner->side && e->health > 0)
|
||||
{
|
||||
|
@ -456,13 +457,13 @@ static Bullet *createBullet(int type, int x, int y, Entity *owner)
|
|||
void fireGuns(Entity *owner)
|
||||
{
|
||||
Bullet *b;
|
||||
int i;
|
||||
float x, y;
|
||||
float c, s;
|
||||
int i;
|
||||
float x, y;
|
||||
float c, s;
|
||||
|
||||
b = NULL;
|
||||
|
||||
for (i = 0 ; i < MAX_FIGHTER_GUNS ; i++)
|
||||
for (i = 0; i < MAX_FIGHTER_GUNS; i++)
|
||||
{
|
||||
if (owner->guns[i].type != BT_NONE && (owner->guns[i].type == owner->selectedGunType || owner->combinedGuns))
|
||||
{
|
||||
|
|
|
@ -19,31 +19,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "capitalShips.h"
|
||||
|
||||
#include "../battle/ai.h"
|
||||
#include "../battle/debris.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "../battle/entities.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../battle/messageBox.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/util.h"
|
||||
#include "../battle/ai.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../battle/debris.h"
|
||||
#include "../battle/messageBox.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/io.h"
|
||||
#include "../battle/entities.h"
|
||||
#include "capitalShips.h"
|
||||
|
||||
#define TURN_SPEED 0.1
|
||||
#define TURN_THRESHOLD 2
|
||||
#define TURN_SPEED 0.1
|
||||
#define TURN_THRESHOLD 2
|
||||
|
||||
extern Battle battle;
|
||||
extern Battle battle;
|
||||
extern Entity *player;
|
||||
extern Entity *self;
|
||||
|
||||
static int steer(void);
|
||||
static int steer(void);
|
||||
static void think(void);
|
||||
static void gunThink(void);
|
||||
static void gunDie(void);
|
||||
|
@ -69,7 +70,7 @@ Entity *spawnCapitalShip(char *name, int x, int y, int side)
|
|||
|
||||
capitalShip = NULL;
|
||||
|
||||
for (def = defHead.next ; def != NULL ; def = def->next)
|
||||
for (def = defHead.next; def != NULL; def = def->next)
|
||||
{
|
||||
if ((strcmp(def->name, name) == 0) || (def->owner != NULL && strcmp(def->owner->name, name) == 0))
|
||||
{
|
||||
|
@ -143,7 +144,7 @@ void doCapitalShip(void)
|
|||
static void think(void)
|
||||
{
|
||||
float dir;
|
||||
int wantedAngle;
|
||||
int wantedAngle;
|
||||
|
||||
if (--self->aiActionTime <= 0)
|
||||
{
|
||||
|
@ -168,13 +169,13 @@ static void think(void)
|
|||
|
||||
static void findAITarget(void)
|
||||
{
|
||||
Entity *e;
|
||||
Entity *e;
|
||||
unsigned int dist, closest;
|
||||
|
||||
self->target = NULL;
|
||||
dist = closest = MAX_TARGET_RANGE;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->active && e->side != self->side && e->flags & EF_AI_TARGET)
|
||||
{
|
||||
|
@ -206,13 +207,13 @@ static void findAITarget(void)
|
|||
|
||||
static int steer(void)
|
||||
{
|
||||
int wantedAngle;
|
||||
int angle;
|
||||
int distance;
|
||||
float dx, dy, force;
|
||||
int count;
|
||||
int wantedAngle;
|
||||
int angle;
|
||||
int distance;
|
||||
float dx, dy, force;
|
||||
int count;
|
||||
Entity *e, **candidates;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
dx = dy = 0;
|
||||
count = 0;
|
||||
|
@ -220,7 +221,7 @@ static int steer(void)
|
|||
|
||||
candidates = getAllEntsInRadius(self->x, self->y, 2000, self);
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if (e->type == ET_CAPITAL_SHIP)
|
||||
{
|
||||
|
@ -299,7 +300,7 @@ static void gunDie(void)
|
|||
playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y);
|
||||
addDebris(self->x, self->y, 3 + rand() % 4);
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e != self && e->health > 0 && e->owner == self->owner && e->type == ET_COMPONENT_GUN)
|
||||
{
|
||||
|
@ -336,7 +337,7 @@ static void engineDie(void)
|
|||
playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y);
|
||||
addDebris(self->x, self->y, 4 + rand() % 9);
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e != self && e->health > 0 && e->owner == self->owner && e->type == ET_COMPONENT_ENGINE)
|
||||
{
|
||||
|
@ -377,7 +378,7 @@ static void die(void)
|
|||
|
||||
addDebris(self->x, self->y, 12);
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->owner == self)
|
||||
{
|
||||
|
@ -410,7 +411,7 @@ static void disable(void)
|
|||
|
||||
runScriptFunction("CAP_DISABLED %s", self->owner->name);
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->owner == self->owner || e == self->owner)
|
||||
{
|
||||
|
@ -426,15 +427,15 @@ static void disable(void)
|
|||
void loadCapitalShipDefs(void)
|
||||
{
|
||||
char **filenames;
|
||||
char path[MAX_FILENAME_LENGTH];
|
||||
int count, i;
|
||||
char path[MAX_FILENAME_LENGTH];
|
||||
int count, i;
|
||||
|
||||
memset(&defHead, 0, sizeof(Entity));
|
||||
defTail = &defHead;
|
||||
|
||||
filenames = getFileList("data/capitalShips", &count);
|
||||
|
||||
for (i = 0 ; i < count ; i++)
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
sprintf(path, "data/capitalShips/%s", filenames[i]);
|
||||
|
||||
|
@ -448,8 +449,8 @@ void loadCapitalShipDefs(void)
|
|||
|
||||
static void loadCapitalShipDef(char *filename)
|
||||
{
|
||||
cJSON *root;
|
||||
char *text;
|
||||
cJSON *root;
|
||||
char *text;
|
||||
Entity *e;
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Loading %s", filename);
|
||||
|
@ -504,7 +505,7 @@ static void loadCapitalShipDef(char *filename)
|
|||
static void loadComponents(Entity *parent, cJSON *components)
|
||||
{
|
||||
Entity *e;
|
||||
cJSON *component;
|
||||
cJSON *component;
|
||||
|
||||
parent->health = 0;
|
||||
|
||||
|
@ -558,7 +559,7 @@ static void loadComponents(Entity *parent, cJSON *components)
|
|||
static void loadGuns(Entity *parent, cJSON *guns)
|
||||
{
|
||||
Entity *e;
|
||||
cJSON *gun;
|
||||
cJSON *gun;
|
||||
|
||||
if (guns)
|
||||
{
|
||||
|
@ -610,7 +611,7 @@ static void loadGuns(Entity *parent, cJSON *guns)
|
|||
static void loadEngines(Entity *parent, cJSON *engines)
|
||||
{
|
||||
Entity *e;
|
||||
cJSON *engine;
|
||||
cJSON *engine;
|
||||
|
||||
if (engines)
|
||||
{
|
||||
|
@ -660,7 +661,7 @@ void updateCapitalShipComponentProperties(Entity *parent, long flags)
|
|||
flags &= ~EF_AI_LEADER;
|
||||
}
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->owner == parent)
|
||||
{
|
||||
|
@ -698,11 +699,11 @@ void updateCapitalShipComponentProperties(Entity *parent, long flags)
|
|||
void loadCapitalShips(cJSON *node)
|
||||
{
|
||||
Entity *e;
|
||||
char **types, *name, *groupName, *type;
|
||||
int side, scatter, number, active;
|
||||
int i, numTypes, addFlags;
|
||||
long flags;
|
||||
float x, y;
|
||||
char **types, *name, *groupName, *type;
|
||||
int side, scatter, number, active;
|
||||
int i, numTypes, addFlags;
|
||||
long flags;
|
||||
float x, y;
|
||||
|
||||
if (node)
|
||||
{
|
||||
|
@ -729,7 +730,7 @@ void loadCapitalShips(cJSON *node)
|
|||
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring, &addFlags);
|
||||
}
|
||||
|
||||
for (i = 0 ; i < number ; i++)
|
||||
for (i = 0; i < number; i++)
|
||||
{
|
||||
type = types[rand() % numTypes];
|
||||
|
||||
|
@ -774,7 +775,7 @@ void loadCapitalShips(cJSON *node)
|
|||
|
||||
node = node->next;
|
||||
|
||||
for (i = 0 ; i < numTypes ; i++)
|
||||
for (i = 0; i < numTypes; i++)
|
||||
{
|
||||
free(types[i]);
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void destroyCapitalShipDefs(void);
|
||||
void loadCapitalShips(struct cJSON *node);
|
||||
void updateCapitalShipComponentProperties(Entity *parent, long flags);
|
||||
void loadCapitalShipDefs(void);
|
||||
void doCapitalShip(void);
|
||||
void destroyCapitalShipDefs(void);
|
||||
void loadCapitalShips(struct cJSON *node);
|
||||
void updateCapitalShipComponentProperties(Entity *parent, long flags);
|
||||
void loadCapitalShipDefs(void);
|
||||
void doCapitalShip(void);
|
||||
Entity *spawnCapitalShip(char *name, int x, int y, int side);
|
||||
|
|
|
@ -19,24 +19,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "debris.h"
|
||||
|
||||
#include "../battle/effects.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/util.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "debris.h"
|
||||
|
||||
#define INITIAL_DEBRIS_DRAW_CAPACITY 32
|
||||
#define MAX_DEBRIS_TEXTURES 6
|
||||
#define INITIAL_DEBRIS_DRAW_CAPACITY 32
|
||||
#define MAX_DEBRIS_TEXTURES 6
|
||||
|
||||
extern Battle battle;
|
||||
|
||||
static void changeCourse(Debris *d);
|
||||
static void resizeDrawList(void);
|
||||
|
||||
static Debris **debrisToDraw;
|
||||
static Debris **debrisToDraw;
|
||||
static AtlasImage *debrisTexture[MAX_DEBRIS_TEXTURES];
|
||||
static int drawCapacity;
|
||||
static int drawCapacity;
|
||||
|
||||
void initDebris(void)
|
||||
{
|
||||
|
@ -49,16 +50,16 @@ void initDebris(void)
|
|||
|
||||
drawCapacity = INITIAL_DEBRIS_DRAW_CAPACITY;
|
||||
|
||||
debrisToDraw = malloc(sizeof(Bullet*) * drawCapacity);
|
||||
memset(debrisToDraw, 0, sizeof(Bullet*) * drawCapacity);
|
||||
debrisToDraw = malloc(sizeof(Bullet *) * drawCapacity);
|
||||
memset(debrisToDraw, 0, sizeof(Bullet *) * drawCapacity);
|
||||
}
|
||||
|
||||
void addDebris(int x, int y, int amount)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Debris *d;
|
||||
|
||||
for (i = 0 ; i < amount ; i++)
|
||||
for (i = 0; i < amount; i++)
|
||||
{
|
||||
d = malloc(sizeof(Debris));
|
||||
memset(d, 0, sizeof(Debris));
|
||||
|
@ -79,16 +80,16 @@ void addDebris(int x, int y, int amount)
|
|||
|
||||
void doDebris(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Debris *d, *prev;
|
||||
|
||||
memset(debrisToDraw, 0, sizeof(Debris*) * drawCapacity);
|
||||
memset(debrisToDraw, 0, sizeof(Debris *) * drawCapacity);
|
||||
|
||||
prev = &battle.debrisHead;
|
||||
|
||||
i = 0;
|
||||
|
||||
for (d = battle.debrisHead.next ; d != NULL ; d = d->next)
|
||||
for (d = battle.debrisHead.next; d != NULL; d = d->next)
|
||||
{
|
||||
d->x += d->dx;
|
||||
d->y += d->dy;
|
||||
|
@ -138,7 +139,7 @@ static void resizeDrawList(void)
|
|||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Resizing debris draw capacity: %d -> %d", drawCapacity, n);
|
||||
|
||||
debrisToDraw = resize(debrisToDraw, sizeof(Debris*) * drawCapacity, sizeof(Debris*) * n);
|
||||
debrisToDraw = resize(debrisToDraw, sizeof(Debris *) * drawCapacity, sizeof(Debris *) * n);
|
||||
drawCapacity = n;
|
||||
}
|
||||
|
||||
|
@ -159,10 +160,10 @@ static void changeCourse(Debris *d)
|
|||
|
||||
void drawDebris(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Debris *d;
|
||||
|
||||
for (i = 0, d = debrisToDraw[i] ; d != NULL ; d = debrisToDraw[++i])
|
||||
for (i = 0, d = debrisToDraw[i]; d != NULL; d = debrisToDraw[++i])
|
||||
{
|
||||
blitRotated(d->texture, d->x - battle.camera.x, d->y - battle.camera.y, d->angle);
|
||||
}
|
||||
|
|
|
@ -19,27 +19,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "effects.h"
|
||||
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/util.h"
|
||||
#include "effects.h"
|
||||
|
||||
#define INITIAL_EFFECT_DRAW_CAPACITY 128
|
||||
#define INITIAL_EFFECT_DRAW_CAPACITY 128
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Entity *self;
|
||||
|
||||
static void setRandomFlameHue(Effect *e);
|
||||
static void setRandomShieldHue(Effect *e);
|
||||
static void resizeDrawList(void);
|
||||
static int pointOnScreen(float x, float y);
|
||||
static int pointOnScreen(float x, float y);
|
||||
|
||||
static AtlasImage *explosionTexture;
|
||||
static AtlasImage *shieldHitTexture;
|
||||
static AtlasImage *haloTexture;
|
||||
static Effect **effectsToDraw;
|
||||
static int drawCapacity;
|
||||
static Effect **effectsToDraw;
|
||||
static int drawCapacity;
|
||||
|
||||
void initEffects(void)
|
||||
{
|
||||
|
@ -49,21 +50,21 @@ void initEffects(void)
|
|||
|
||||
drawCapacity = INITIAL_EFFECT_DRAW_CAPACITY;
|
||||
|
||||
effectsToDraw = malloc(sizeof(Effect*) * drawCapacity);
|
||||
memset(effectsToDraw, 0, sizeof(Effect*) * drawCapacity);
|
||||
effectsToDraw = malloc(sizeof(Effect *) * drawCapacity);
|
||||
memset(effectsToDraw, 0, sizeof(Effect *) * drawCapacity);
|
||||
}
|
||||
|
||||
void doEffects(void)
|
||||
{
|
||||
int i, onScreen;
|
||||
int i, onScreen;
|
||||
Effect *e;
|
||||
Effect *prev = &battle.effectHead;
|
||||
|
||||
i = 0;
|
||||
|
||||
memset(effectsToDraw, 0, sizeof(Effect*) * drawCapacity);
|
||||
memset(effectsToDraw, 0, sizeof(Effect *) * drawCapacity);
|
||||
|
||||
for (e = battle.effectHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.effectHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
e->x += e->dx;
|
||||
e->y += e->dy;
|
||||
|
@ -133,19 +134,19 @@ static void resizeDrawList(void)
|
|||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Resizing effect draw capacity: %d -> %d", drawCapacity, n);
|
||||
|
||||
effectsToDraw = resize(effectsToDraw, sizeof(Effect*) * drawCapacity, sizeof(Effect*) * n);
|
||||
effectsToDraw = resize(effectsToDraw, sizeof(Effect *) * drawCapacity, sizeof(Effect *) * n);
|
||||
|
||||
drawCapacity = n;
|
||||
}
|
||||
|
||||
void drawEffects(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Effect *e;
|
||||
|
||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
||||
|
||||
for (i = 0, e = effectsToDraw[i] ; e != NULL ; e = effectsToDraw[++i])
|
||||
for (i = 0, e = effectsToDraw[i]; e != NULL; e = effectsToDraw[++i])
|
||||
{
|
||||
SDL_SetRenderDrawColor(app.renderer, e->r, e->g, e->b, e->a);
|
||||
|
||||
|
@ -201,9 +202,9 @@ void drawShieldHitEffect(Entity *e)
|
|||
void addBulletHitEffect(int x, int y, int r, int g, int b)
|
||||
{
|
||||
Effect *e;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < 4 ; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
|
@ -281,10 +282,10 @@ void addDebrisFire(int x, int y)
|
|||
|
||||
void addSmallExplosion(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Effect *e;
|
||||
|
||||
for (i = 0 ; i < 32 ; i++)
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
|
@ -312,7 +313,7 @@ void addSmallExplosion(void)
|
|||
e->y -= e->size / 2;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < 96 ; i++)
|
||||
for (i = 0; i < 96; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
|
@ -336,10 +337,10 @@ void addSmallExplosion(void)
|
|||
|
||||
void addMineExplosion(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Effect *e;
|
||||
|
||||
for (i = 0 ; i < 64 ; i++)
|
||||
for (i = 0; i < 64; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
|
@ -386,10 +387,10 @@ void addMineExplosion(void)
|
|||
|
||||
void addLargeExplosion(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Effect *e;
|
||||
|
||||
for (i = 0 ; i < 64 ; i++)
|
||||
for (i = 0; i < 64; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
|
@ -440,10 +441,10 @@ void addLargeExplosion(void)
|
|||
|
||||
void addMissileExplosion(Bullet *b)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Effect *e;
|
||||
|
||||
for (i = 0 ; i < 8 ; i++)
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
|
@ -471,7 +472,7 @@ void addMissileExplosion(Bullet *b)
|
|||
e->y -= e->size / 2;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < 24 ; i++)
|
||||
for (i = 0; i < 24; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
|
@ -496,8 +497,8 @@ void addMissileExplosion(Bullet *b)
|
|||
void addEngineEffect(void)
|
||||
{
|
||||
Effect *e;
|
||||
float c, s;
|
||||
int h;
|
||||
float c, s;
|
||||
int h;
|
||||
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
|
@ -595,10 +596,10 @@ void addMissileEngineEffect(Bullet *b)
|
|||
|
||||
void addShieldSplinterEffect(Entity *ent)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Effect *e;
|
||||
|
||||
for (i = 0 ; i < 48 ; i++)
|
||||
for (i = 0; i < 48; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
|
@ -622,10 +623,10 @@ void addShieldSplinterEffect(Entity *ent)
|
|||
|
||||
void addECMEffect(Entity *ent)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Effect *e;
|
||||
|
||||
for (i = 0 ; i < 3 ; i++)
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
|
||||
|
|
|
@ -19,24 +19,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "entities.h"
|
||||
#include "../system/lookup.h"
|
||||
|
||||
#include "../battle/capitalShips.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../battle/rope.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "entities.h"
|
||||
|
||||
#define DISABLED_GLOW_MAX 255
|
||||
#define DISABLED_GLOW_MIN 128
|
||||
#define DISABLED_GLOW_SPEED 3
|
||||
#define DISABLED_GLOW_MAX 255
|
||||
#define DISABLED_GLOW_MIN 128
|
||||
#define DISABLED_GLOW_SPEED 3
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Dev dev;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Dev dev;
|
||||
extern Entity *player;
|
||||
extern Entity *self;
|
||||
|
||||
|
@ -47,14 +48,14 @@ static void activateEpicFighters(int side);
|
|||
static void restrictToBattleArea(Entity *e);
|
||||
static void drawTargetRects(Entity *e);
|
||||
static void drawHealthBar(Entity *e);
|
||||
static int drawComparator(const void *a, const void *b);
|
||||
static int drawComparator(const void *a, const void *b);
|
||||
static void notifyNewArrivals(void);
|
||||
static int isComponent(Entity *e);
|
||||
static int isComponent(Entity *e);
|
||||
|
||||
static Entity deadHead;
|
||||
static Entity deadHead;
|
||||
static Entity *deadTail;
|
||||
static int disabledGlow;
|
||||
static int disabledGlowDir;
|
||||
static int disabledGlow;
|
||||
static int disabledGlowDir;
|
||||
|
||||
void initEntities(void)
|
||||
{
|
||||
|
@ -80,9 +81,9 @@ Entity *spawnEntity(void)
|
|||
|
||||
void doEntities(void)
|
||||
{
|
||||
int numAllies, numEnemies;
|
||||
int numActiveAllies, numActiveEnemies;
|
||||
int numSpawnedEnemies;
|
||||
int numAllies, numEnemies;
|
||||
int numActiveAllies, numActiveEnemies;
|
||||
int numSpawnedEnemies;
|
||||
Entity *e, *prev;
|
||||
|
||||
prev = &battle.entityHead;
|
||||
|
@ -95,7 +96,7 @@ void doEntities(void)
|
|||
player->shield = player->maxShield;
|
||||
}
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
removeFromQuadtree(e, &battle.quadtree);
|
||||
|
||||
|
@ -198,7 +199,7 @@ void doEntities(void)
|
|||
|
||||
if (e->killedBy == player && battle.hasSuspicionLevel)
|
||||
{
|
||||
if (e->aiFlags & (AIF_AVOIDS_COMBAT|AIF_DEFENSIVE))
|
||||
if (e->aiFlags & (AIF_AVOIDS_COMBAT | AIF_DEFENSIVE))
|
||||
{
|
||||
battle.suspicionLevel -= (MAX_SUSPICION_LEVEL * 0.5);
|
||||
}
|
||||
|
@ -369,10 +370,10 @@ static void doEntity(void)
|
|||
static void alignComponents(void)
|
||||
{
|
||||
Entity *e;
|
||||
float x, y;
|
||||
float c, s;
|
||||
float x, y;
|
||||
float c, s;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (isComponent(e))
|
||||
{
|
||||
|
@ -407,17 +408,19 @@ static int isComponent(Entity *e)
|
|||
|
||||
void drawEntities(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Entity *e, **candidates;
|
||||
|
||||
candidates = getAllEntsWithin(battle.camera.x, battle.camera.y, app.winWidth, app.winHeight, NULL);
|
||||
|
||||
/* counting entities to draw */
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i]) {};
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
};
|
||||
|
||||
qsort(candidates, i, sizeof(Entity*), drawComparator);
|
||||
qsort(candidates, i, sizeof(Entity *), drawComparator);
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
self = e;
|
||||
|
||||
|
@ -545,13 +548,13 @@ static void drawTargetRects(Entity *e)
|
|||
void activateEntities(char *names)
|
||||
{
|
||||
Entity *e;
|
||||
char *name;
|
||||
char *name;
|
||||
|
||||
name = strtok(names, ";");
|
||||
|
||||
while (name)
|
||||
{
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (strcmp(e->name, name) == 0)
|
||||
{
|
||||
|
@ -573,13 +576,13 @@ void activateEntities(char *names)
|
|||
void activateEntityGroups(char *groupNames)
|
||||
{
|
||||
Entity *e;
|
||||
char *groupName;
|
||||
char *groupName;
|
||||
|
||||
groupName = strtok(groupNames, ";");
|
||||
|
||||
while (groupName)
|
||||
{
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (strcmp(e->groupName, groupName) == 0)
|
||||
{
|
||||
|
@ -608,7 +611,7 @@ static void notifyNewArrivals(void)
|
|||
{
|
||||
Entity *e;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->active && (e->type == ET_FIGHTER || e->type == ET_CAPITAL_SHIP))
|
||||
{
|
||||
|
@ -621,7 +624,7 @@ static void activateEpicFighters(int side)
|
|||
{
|
||||
Entity *e;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (!e->active && e->type == ET_FIGHTER && !(e->flags & EF_NO_EPIC) && ((side == SIDE_ALLIES && e->side == SIDE_ALLIES) || (side != SIDE_ALLIES && e->side != SIDE_ALLIES)))
|
||||
{
|
||||
|
@ -646,7 +649,7 @@ void countNumEnemies(void)
|
|||
{
|
||||
Entity *e;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->side != SIDE_ALLIES && (e->type == ET_FIGHTER || e->type == ET_CAPITAL_SHIP) && (!(e->flags & EF_NO_THREAT)))
|
||||
{
|
||||
|
@ -661,7 +664,7 @@ void addAllToQuadtree(void)
|
|||
{
|
||||
Entity *e;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->active)
|
||||
{
|
||||
|
@ -672,8 +675,8 @@ void addAllToQuadtree(void)
|
|||
|
||||
static int drawComparator(const void *a, const void *b)
|
||||
{
|
||||
Entity *e1 = *((Entity**)a);
|
||||
Entity *e2 = *((Entity**)b);
|
||||
Entity *e1 = *((Entity **)a);
|
||||
Entity *e2 = *((Entity **)b);
|
||||
|
||||
return e2->type - e1->type;
|
||||
}
|
||||
|
@ -682,7 +685,7 @@ void killEntity(char *name)
|
|||
{
|
||||
Entity *e;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (strcmp(e->name, name) == 0)
|
||||
{
|
||||
|
@ -699,11 +702,11 @@ void killEntity(char *name)
|
|||
void updateEntitySide(char *sideStr, char *name)
|
||||
{
|
||||
Entity *e;
|
||||
int side;
|
||||
int side;
|
||||
|
||||
side = lookup(sideStr);
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (strcmp(e->name, name) == 0)
|
||||
{
|
||||
|
@ -721,7 +724,7 @@ void awardPandoranCraftTrophy(void)
|
|||
{
|
||||
Entity *e;
|
||||
|
||||
for (e = deadHead.next ; e != NULL ; e = e->next)
|
||||
for (e = deadHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->killedBy == player && e->side == SIDE_PANDORAN)
|
||||
{
|
||||
|
|
|
@ -18,15 +18,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void destroyEntities(void);
|
||||
void awardPandoranCraftTrophy(void);
|
||||
void updateEntitySide(char *sideStr, char *name);
|
||||
void killEntity(char *name);
|
||||
void addAllToQuadtree(void);
|
||||
void countNumEnemies(void);
|
||||
void activateEntityGroups(char *groupNames);
|
||||
void activateEntities(char *names);
|
||||
void drawEntities(void);
|
||||
void doEntities(void);
|
||||
void destroyEntities(void);
|
||||
void awardPandoranCraftTrophy(void);
|
||||
void updateEntitySide(char *sideStr, char *name);
|
||||
void killEntity(char *name);
|
||||
void addAllToQuadtree(void);
|
||||
void countNumEnemies(void);
|
||||
void activateEntityGroups(char *groupNames);
|
||||
void activateEntities(char *names);
|
||||
void drawEntities(void);
|
||||
void doEntities(void);
|
||||
Entity *spawnEntity(void);
|
||||
void initEntities(void);
|
||||
void initEntities(void);
|
||||
|
|
|
@ -19,44 +19,45 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "fighters.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/util.h"
|
||||
#include "../battle/ai.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../battle/debris.h"
|
||||
#include "../battle/rope.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../battle/hud.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "../battle/items.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../battle/entities.h"
|
||||
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
#include "../battle/ai.h"
|
||||
#include "../battle/debris.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "../battle/entities.h"
|
||||
#include "../battle/hud.h"
|
||||
#include "../battle/items.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../battle/rope.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/util.h"
|
||||
#include "fighters.h"
|
||||
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Entity *player;
|
||||
extern Entity *self;
|
||||
extern Game game;
|
||||
extern Game game;
|
||||
|
||||
static void separate(void);
|
||||
static void die(void);
|
||||
static void immediateDie(void);
|
||||
static void spinDie(void);
|
||||
static void straightDie(void);
|
||||
static void simpleDie(void);
|
||||
static void randomizeDart(Entity *dart);
|
||||
static void randomizeDartGuns(Entity *dart);
|
||||
static void loadFighterDef(char *filename);
|
||||
static void loadFighterDefList(char *filename);
|
||||
static void separate(void);
|
||||
static void die(void);
|
||||
static void immediateDie(void);
|
||||
static void spinDie(void);
|
||||
static void straightDie(void);
|
||||
static void simpleDie(void);
|
||||
static void randomizeDart(Entity *dart);
|
||||
static void randomizeDartGuns(Entity *dart);
|
||||
static void loadFighterDef(char *filename);
|
||||
static void loadFighterDefList(char *filename);
|
||||
static Entity *getFighterDef(char *name);
|
||||
static void addFighterStat(char *name);
|
||||
static void incFighterStat(char *key);
|
||||
static void addFighterStat(char *name);
|
||||
static void incFighterStat(char *key);
|
||||
|
||||
static Entity defHead, *defTail;
|
||||
|
||||
|
@ -175,7 +176,7 @@ static void randomizeDartGuns(Entity *dart)
|
|||
dart->guns[0].type = BT_PLASMA;
|
||||
dart->guns[0].x = dart->guns[0].y = 0;
|
||||
|
||||
for (i = 1 ; i < MAX_FIGHTER_GUNS ; i++)
|
||||
for (i = 1; i < MAX_FIGHTER_GUNS; i++)
|
||||
{
|
||||
if (dart->guns[i].type)
|
||||
{
|
||||
|
@ -408,12 +409,12 @@ void doFighter(void)
|
|||
|
||||
static void separate(void)
|
||||
{
|
||||
int angle;
|
||||
int distance;
|
||||
float dx, dy, force;
|
||||
int count;
|
||||
int angle;
|
||||
int distance;
|
||||
float dx, dy, force;
|
||||
int count;
|
||||
Entity *e, **candidates;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
dx = dy = 0;
|
||||
count = 0;
|
||||
|
@ -421,7 +422,7 @@ static void separate(void)
|
|||
|
||||
candidates = getAllEntsInRadius(self->x, self->y, self->separationRadius, self);
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if ((e->flags & EF_TAKES_DAMAGE) && (!(e->flags & EF_NON_SOLID)))
|
||||
{
|
||||
|
@ -706,7 +707,7 @@ void retreatEnemies(void)
|
|||
{
|
||||
Entity *e;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->type == ET_FIGHTER && e->side != player->side)
|
||||
{
|
||||
|
@ -731,7 +732,7 @@ void retreatAllies(void)
|
|||
{
|
||||
Entity *e;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->type == ET_FIGHTER && e->side == player->side)
|
||||
{
|
||||
|
@ -758,7 +759,7 @@ static Entity *getFighterDef(char *name)
|
|||
{
|
||||
Entity *e;
|
||||
|
||||
for (e = defHead.next ; e != NULL ; e = e->next)
|
||||
for (e = defHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (strcmp(e->name, name) == 0)
|
||||
{
|
||||
|
@ -773,11 +774,11 @@ static Entity *getFighterDef(char *name)
|
|||
Entity **getDBFighters(int *num)
|
||||
{
|
||||
Entity *e, **dbFighters;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
i = *num = 0;
|
||||
|
||||
for (e = defHead.next ; e != NULL ; e = e->next)
|
||||
for (e = defHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->description != NULL)
|
||||
{
|
||||
|
@ -785,9 +786,9 @@ Entity **getDBFighters(int *num)
|
|||
}
|
||||
}
|
||||
|
||||
dbFighters = malloc(sizeof(Entity*) * *num);
|
||||
dbFighters = malloc(sizeof(Entity *) * *num);
|
||||
|
||||
for (e = defHead.next ; e != NULL ; e = e->next)
|
||||
for (e = defHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->description != NULL)
|
||||
{
|
||||
|
@ -813,12 +814,12 @@ void loadFighterDefs(void)
|
|||
static void loadFighterDefList(char *dir)
|
||||
{
|
||||
char **filenames;
|
||||
char path[MAX_FILENAME_LENGTH];
|
||||
int count, i;
|
||||
char path[MAX_FILENAME_LENGTH];
|
||||
int count, i;
|
||||
|
||||
filenames = getFileList(dir, &count);
|
||||
|
||||
for (i = 0 ; i < count ; i++)
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
sprintf(path, "%s/%s", dir, filenames[i]);
|
||||
|
||||
|
@ -832,10 +833,10 @@ static void loadFighterDefList(char *dir)
|
|||
|
||||
static void loadFighterDef(char *filename)
|
||||
{
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
Entity *e;
|
||||
int i, len;
|
||||
int i, len;
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Loading %s", filename);
|
||||
|
||||
|
@ -877,7 +878,7 @@ static void loadFighterDef(char *filename)
|
|||
{
|
||||
i = 0;
|
||||
|
||||
for (node = cJSON_GetObjectItem(root, "guns")->child ; node != NULL ; node = node->next)
|
||||
for (node = cJSON_GetObjectItem(root, "guns")->child; node != NULL; node = node->next)
|
||||
{
|
||||
e->guns[i].type = lookup(cJSON_GetObjectItem(node, "type")->valuestring);
|
||||
e->guns[i].x = cJSON_GetObjectItem(node, "x")->valueint;
|
||||
|
@ -939,7 +940,7 @@ static void addFighterStat(char *key)
|
|||
|
||||
tail = &game.fighterStatHead;
|
||||
|
||||
for (t = game.fighterStatHead.next ; t != NULL ; t = t->next)
|
||||
for (t = game.fighterStatHead.next; t != NULL; t = t->next)
|
||||
{
|
||||
if (strcmp(t->key, key) == 0)
|
||||
{
|
||||
|
@ -963,7 +964,7 @@ static void incFighterStat(char *key)
|
|||
{
|
||||
Tuple *t;
|
||||
|
||||
for (t = game.fighterStatHead.next ; t != NULL ; t = t->next)
|
||||
for (t = game.fighterStatHead.next; t != NULL; t = t->next)
|
||||
{
|
||||
if (strcmp(t->key, key) == 0)
|
||||
{
|
||||
|
@ -976,11 +977,11 @@ static void incFighterStat(char *key)
|
|||
void loadFighters(cJSON *node)
|
||||
{
|
||||
Entity *e;
|
||||
char **types, *name, *groupName, *type, *strpos;
|
||||
int side, scatter, number, active;
|
||||
int i, numTypes, addFlags, addAIFlags, id;
|
||||
long flags, aiFlags;
|
||||
float x, y;
|
||||
char **types, *name, *groupName, *type, *strpos;
|
||||
int side, scatter, number, active;
|
||||
int i, numTypes, addFlags, addAIFlags, id;
|
||||
long flags, aiFlags;
|
||||
float x, y;
|
||||
|
||||
if (node)
|
||||
{
|
||||
|
@ -1015,7 +1016,7 @@ void loadFighters(cJSON *node)
|
|||
aiFlags = flagsToLong(cJSON_GetObjectItem(node, "aiFlags")->valuestring, &addAIFlags);
|
||||
}
|
||||
|
||||
for (i = 0 ; i < number ; i++)
|
||||
for (i = 0; i < number; i++)
|
||||
{
|
||||
type = types[rand() % numTypes];
|
||||
|
||||
|
@ -1083,7 +1084,7 @@ void loadFighters(cJSON *node)
|
|||
|
||||
node = node->next;
|
||||
|
||||
for (i = 0 ; i < numTypes ; i++)
|
||||
for (i = 0; i < numTypes; i++)
|
||||
{
|
||||
free(types[i]);
|
||||
}
|
||||
|
|
|
@ -18,16 +18,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void destroyFighterStats(void);
|
||||
void destroyFighterDefs(void);
|
||||
void loadFighters(struct cJSON *node);
|
||||
void loadFighterDefs(void);
|
||||
void destroyFighterStats(void);
|
||||
void destroyFighterDefs(void);
|
||||
void loadFighters(struct cJSON *node);
|
||||
void loadFighterDefs(void);
|
||||
Entity **getDBFighters(int *num);
|
||||
void retreatAllies(void);
|
||||
void retreatEnemies(void);
|
||||
void damageFighter(Entity *e, int amount, long flags);
|
||||
void applyFighterBrakes(void);
|
||||
void applyFighterThrust(void);
|
||||
void doFighter(void);
|
||||
void resetFighter(Entity *fighter);
|
||||
Entity *spawnFighter(char *name, int x, int y, int side);
|
||||
void retreatAllies(void);
|
||||
void retreatEnemies(void);
|
||||
void damageFighter(Entity *e, int amount, long flags);
|
||||
void applyFighterBrakes(void);
|
||||
void applyFighterThrust(void);
|
||||
void doFighter(void);
|
||||
void resetFighter(Entity *fighter);
|
||||
Entity *spawnFighter(char *name, int x, int y, int side);
|
||||
|
|
|
@ -19,22 +19,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "hud.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/util.h"
|
||||
#include "../battle/player.h"
|
||||
#include "../system/text.h"
|
||||
#include "../battle/radar.h"
|
||||
#include "../system/draw.h"
|
||||
|
||||
#include "../battle/jumpgate.h"
|
||||
#include "../battle/player.h"
|
||||
#include "../battle/radar.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/util.h"
|
||||
#include "hud.h"
|
||||
|
||||
#define MAX_HUD_MESSAGES 6
|
||||
#define MAX_HUD_MESSAGES 6
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Entity *player;
|
||||
extern Game game;
|
||||
extern Game game;
|
||||
|
||||
static void drawPlayerTargeter(void);
|
||||
static void drawNumFighters(void);
|
||||
|
@ -50,7 +51,7 @@ static void drawHealthShieldBar(int current, int max, int x, int y, int r, int g
|
|||
static void drawSuspicionLevel(void);
|
||||
static void drawMissileWarning(void);
|
||||
|
||||
static HudMessage hudMessageHead;
|
||||
static HudMessage hudMessageHead;
|
||||
static HudMessage *hudMessageTail;
|
||||
static AtlasImage *targetPointer;
|
||||
static AtlasImage *targetCircle;
|
||||
|
@ -64,21 +65,21 @@ static AtlasImage *boost;
|
|||
static AtlasImage *nextGun;
|
||||
static AtlasImage *clockIcon;
|
||||
static AtlasImage *objectives;
|
||||
static int numMessages;
|
||||
static int numMessages;
|
||||
static const char *gunName[BT_MAX];
|
||||
static char *MISSILES_TEXT;
|
||||
static char *TARGET_TEXT;
|
||||
static char *NONE_TEXT;
|
||||
static char *COMBINED_TEXT;
|
||||
static char *SYSTEM_POWER_TEXT;
|
||||
static char *LEADER_DIST_TEXT;
|
||||
static char *TARGET_DIST_TEXT;
|
||||
static char *OBJECTIVE_DIST_TEXT;
|
||||
static char *JUMPGATE_DIST_TEXT;
|
||||
static char *NEW_FIGHTER_TEXT;
|
||||
static char *SUSPICION_TEXT;
|
||||
static char *REMAINING_PILOTS_TEXT;
|
||||
static char *WARNING_TEXT;
|
||||
static char *MISSILES_TEXT;
|
||||
static char *TARGET_TEXT;
|
||||
static char *NONE_TEXT;
|
||||
static char *COMBINED_TEXT;
|
||||
static char *SYSTEM_POWER_TEXT;
|
||||
static char *LEADER_DIST_TEXT;
|
||||
static char *TARGET_DIST_TEXT;
|
||||
static char *OBJECTIVE_DIST_TEXT;
|
||||
static char *JUMPGATE_DIST_TEXT;
|
||||
static char *NEW_FIGHTER_TEXT;
|
||||
static char *SUSPICION_TEXT;
|
||||
static char *REMAINING_PILOTS_TEXT;
|
||||
static char *WARNING_TEXT;
|
||||
|
||||
void initHud(void)
|
||||
{
|
||||
|
@ -129,7 +130,7 @@ void doHud(void)
|
|||
|
||||
prev = &hudMessageHead;
|
||||
|
||||
for (hudMessage = hudMessageHead.next ; hudMessage != NULL ; hudMessage = hudMessage->next)
|
||||
for (hudMessage = hudMessageHead.next; hudMessage != NULL; hudMessage = hudMessage->next)
|
||||
{
|
||||
hudMessage->life--;
|
||||
|
||||
|
@ -219,7 +220,7 @@ void drawHud(void)
|
|||
static void drawHealthBars(void)
|
||||
{
|
||||
float p;
|
||||
int r, g, b;
|
||||
int r, g, b;
|
||||
|
||||
r = g = b = 0;
|
||||
p = player->health;
|
||||
|
@ -251,7 +252,7 @@ static void drawHealthBars(void)
|
|||
static void drawHealthShieldBar(int current, int max, int x, int y, int r, int g, int b, int flashLow)
|
||||
{
|
||||
SDL_Rect rect;
|
||||
float percent = 0;
|
||||
float percent = 0;
|
||||
|
||||
if (max > 0)
|
||||
{
|
||||
|
@ -348,7 +349,7 @@ static void drawWeaponInfo(void)
|
|||
{
|
||||
y = 70;
|
||||
|
||||
for (i = 0 ; i < BT_MAX ; i++)
|
||||
for (i = 0; i < BT_MAX; i++)
|
||||
{
|
||||
if (playerHasGun(i))
|
||||
{
|
||||
|
@ -383,7 +384,7 @@ static void drawWeaponInfo(void)
|
|||
static void drawPlayerTargeter(void)
|
||||
{
|
||||
float angle;
|
||||
int x, y;
|
||||
int x, y;
|
||||
|
||||
if (player->target || battle.missionTarget || jumpgateEnabled() || battle.messageSpeaker)
|
||||
{
|
||||
|
@ -559,7 +560,7 @@ static float distanceToKM(int x1, int y1, int x2, int y2)
|
|||
|
||||
static void drawDistancesInfo(void)
|
||||
{
|
||||
int y;
|
||||
int y;
|
||||
float distance;
|
||||
|
||||
y = 11;
|
||||
|
@ -615,9 +616,9 @@ static void drawDistancesInfo(void)
|
|||
static void drawHudMessages(void)
|
||||
{
|
||||
HudMessage *hudMessage;
|
||||
int y = app.winHeight - 25;
|
||||
int y = app.winHeight - 25;
|
||||
|
||||
for (hudMessage = hudMessageHead.next ; hudMessage != NULL ; hudMessage = hudMessage->next)
|
||||
for (hudMessage = hudMessageHead.next; hudMessage != NULL; hudMessage = hudMessage->next)
|
||||
{
|
||||
drawText(10, y, 14, TA_LEFT, hudMessage->color, hudMessage->message);
|
||||
|
||||
|
|
|
@ -19,32 +19,33 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "items.h"
|
||||
|
||||
#include "../battle/entities.h"
|
||||
#include "../battle/hud.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/util.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../battle/hud.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../battle/entities.h"
|
||||
#include "items.h"
|
||||
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Entity *player;
|
||||
extern Entity *self;
|
||||
|
||||
static void action(void);
|
||||
static void action(void);
|
||||
static Entity *getItemDef(char *name);
|
||||
|
||||
static Entity defHead, *defTail;
|
||||
|
||||
void loadItemDefs(void)
|
||||
{
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
Entity *e;
|
||||
|
||||
text = readFile("data/battle/items.json");
|
||||
|
@ -54,7 +55,7 @@ void loadItemDefs(void)
|
|||
memset(&defHead, 0, sizeof(Entity));
|
||||
defTail = &defHead;
|
||||
|
||||
for (node = root->child ; node != NULL ; node = node->next)
|
||||
for (node = root->child; node != NULL; node = node->next)
|
||||
{
|
||||
e = malloc(sizeof(Entity));
|
||||
memset(e, 0, sizeof(Entity));
|
||||
|
@ -92,7 +93,7 @@ Entity *spawnItem(char *name)
|
|||
}
|
||||
else
|
||||
{
|
||||
for (e = defHead.next ; e != NULL ; e = e->next)
|
||||
for (e = defHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (!def || rand() % 2)
|
||||
{
|
||||
|
@ -129,7 +130,7 @@ static Entity *getItemDef(char *defName)
|
|||
{
|
||||
Entity *e;
|
||||
|
||||
for (e = defHead.next ; e != NULL ; e = e->next)
|
||||
for (e = defHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (strcmp(e->defName, defName) == 0)
|
||||
{
|
||||
|
@ -144,11 +145,11 @@ static Entity *getItemDef(char *defName)
|
|||
static void action(void)
|
||||
{
|
||||
Entity *e, **candidates;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
candidates = getAllEntsInRadius(self->x, self->y, MAX(self->w, self->h), self);
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if (e->alive == ALIVE_ALIVE && (e->flags & EF_COLLECTS_ITEMS) && collision(self->x - (self->w / 2), self->y - (self->h / 2), self->w, self->h, e->x - (e->w / 2), e->y - (e->h / 2), e->w, e->h))
|
||||
{
|
||||
|
@ -175,10 +176,10 @@ static void action(void)
|
|||
void loadItems(cJSON *node)
|
||||
{
|
||||
Entity *e;
|
||||
char *name, *groupName, *type;
|
||||
int i, scatter, number, active, addFlags;
|
||||
long flags;
|
||||
float x, y;
|
||||
char *name, *groupName, *type;
|
||||
int i, scatter, number, active, addFlags;
|
||||
long flags;
|
||||
float x, y;
|
||||
|
||||
flags = -1;
|
||||
scatter = 1;
|
||||
|
@ -206,7 +207,7 @@ void loadItems(cJSON *node)
|
|||
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring, &addFlags);
|
||||
}
|
||||
|
||||
for (i = 0 ; i < number ; i++)
|
||||
for (i = 0; i < number; i++)
|
||||
{
|
||||
e = spawnItem(type);
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void destroyItemDefs(void);
|
||||
void loadItems(struct cJSON *node);
|
||||
void addRandomItem(int x, int y);
|
||||
void destroyItemDefs(void);
|
||||
void loadItems(struct cJSON *node);
|
||||
void addRandomItem(int x, int y);
|
||||
Entity *spawnItem(char *name);
|
||||
void loadItemDefs(void);
|
||||
void loadItemDefs(void);
|
||||
|
|
|
@ -19,21 +19,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "jumpgate.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/util.h"
|
||||
#include "../battle/quadtree.h"
|
||||
|
||||
#include "../battle/debris.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../battle/entities.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/util.h"
|
||||
#include "jumpgate.h"
|
||||
|
||||
#define ESCAPE_DISTANCE 256
|
||||
#define ESCAPE_DISTANCE 256
|
||||
|
||||
extern Battle battle;
|
||||
extern Battle battle;
|
||||
extern Entity *self;
|
||||
|
||||
static void think(void);
|
||||
|
@ -44,7 +45,7 @@ static void addNodes(Entity *jumpgate, long flags);
|
|||
static void nodeDie(void);
|
||||
|
||||
static AtlasImage *portal;
|
||||
static float portalAngle;
|
||||
static float portalAngle;
|
||||
|
||||
Entity *spawnJumpgate(int side, long flags)
|
||||
{
|
||||
|
@ -63,7 +64,7 @@ Entity *spawnJumpgate(int side, long flags)
|
|||
jumpgate->action = think;
|
||||
jumpgate->draw = draw;
|
||||
jumpgate->side = side;
|
||||
jumpgate->flags = EF_NO_MT_BOX+EF_IMMORTAL+EF_AI_IGNORE+EF_NON_SOLID+EF_NO_HEALTH_BAR;
|
||||
jumpgate->flags = EF_NO_MT_BOX + EF_IMMORTAL + EF_AI_IGNORE + EF_NON_SOLID + EF_NO_HEALTH_BAR;
|
||||
|
||||
if (flags != -1 && flags & EF_DISABLED)
|
||||
{
|
||||
|
@ -85,13 +86,13 @@ Entity *spawnJumpgate(int side, long flags)
|
|||
|
||||
static void addNodes(Entity *jumpgate, long flags)
|
||||
{
|
||||
Entity *node;
|
||||
Entity *node;
|
||||
AtlasImage *nodeTexture;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
nodeTexture = getAtlasImage("gfx/entities/jumpgateNode.png");
|
||||
|
||||
for (i = 0 ; i < 360 ; i += 36)
|
||||
for (i = 0; i < 360; i += 36)
|
||||
{
|
||||
node = spawnEntity();
|
||||
STRNCPY(node->name, _("Jumpgate System Node"), MAX_NAME_LENGTH);
|
||||
|
@ -102,7 +103,7 @@ static void addNodes(Entity *jumpgate, long flags)
|
|||
node->owner = jumpgate;
|
||||
node->side = jumpgate->side;
|
||||
node->texture = nodeTexture;
|
||||
node->flags = EF_TAKES_DAMAGE+EF_AI_IGNORE;
|
||||
node->flags = EF_TAKES_DAMAGE + EF_AI_IGNORE;
|
||||
node->die = nodeDie;
|
||||
node->w = node->texture->rect.w;
|
||||
node->h = node->texture->rect.h;
|
||||
|
@ -152,7 +153,7 @@ void activateJumpgate(int activate)
|
|||
|
||||
if (battle.jumpgate && battle.jumpgate->health > 1)
|
||||
{
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e == battle.jumpgate || e->owner == battle.jumpgate)
|
||||
{
|
||||
|
@ -196,11 +197,11 @@ static void think(void)
|
|||
static void handleFleeingEntities(void)
|
||||
{
|
||||
Entity *e, **candidates;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
candidates = getAllEntsInRadius(self->x, self->y, ESCAPE_DISTANCE * 2, self);
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if (e->health > 0 && (e->flags & EF_RETREATING) && getDistance(self->x, self->y, e->x, e->y) <= ESCAPE_DISTANCE)
|
||||
{
|
||||
|
@ -216,11 +217,11 @@ static void handleFleeingEntities(void)
|
|||
static void addEscapeEffect(Entity *ent)
|
||||
{
|
||||
Effect *e;
|
||||
int i, n, speed;
|
||||
int i, n, speed;
|
||||
|
||||
n = ent->w * ent->h;
|
||||
|
||||
for (i = 0 ; i < n ; i++)
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
e = malloc(sizeof(Effect));
|
||||
memset(e, 0, sizeof(Effect));
|
||||
|
|
|
@ -18,6 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void activateJumpgate(int activate);
|
||||
int jumpgateEnabled(void);
|
||||
void activateJumpgate(int activate);
|
||||
int jumpgateEnabled(void);
|
||||
Entity *spawnJumpgate(int side, long flags);
|
||||
|
|
|
@ -19,13 +19,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "locations.h"
|
||||
|
||||
#include "../battle/script.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/util.h"
|
||||
#include "../battle/script.h"
|
||||
#include "locations.h"
|
||||
|
||||
extern Battle battle;
|
||||
extern Battle battle;
|
||||
extern Entity *player;
|
||||
|
||||
void doLocations(void)
|
||||
|
@ -34,7 +35,7 @@ void doLocations(void)
|
|||
|
||||
prev = &battle.locationHead;
|
||||
|
||||
for (l = battle.locationHead.next ; l != NULL ; l = l->next)
|
||||
for (l = battle.locationHead.next; l != NULL; l = l->next)
|
||||
{
|
||||
if (l->active && getDistance(player->x, player->y, l->x, l->y) <= l->size)
|
||||
{
|
||||
|
@ -53,7 +54,7 @@ void drawLocations(void)
|
|||
{
|
||||
Location *l;
|
||||
|
||||
for (l = battle.locationHead.next ; l != NULL ; l = l->next)
|
||||
for (l = battle.locationHead.next; l != NULL; l = l->next)
|
||||
{
|
||||
if (l->active)
|
||||
{
|
||||
|
@ -64,14 +65,14 @@ void drawLocations(void)
|
|||
|
||||
void activateLocations(char *locations)
|
||||
{
|
||||
char *token;
|
||||
char *token;
|
||||
Location *l;
|
||||
|
||||
token = strtok(locations, ";");
|
||||
|
||||
while (token)
|
||||
{
|
||||
for (l = battle.locationHead.next ; l != NULL ; l = l->next)
|
||||
for (l = battle.locationHead.next; l != NULL; l = l->next)
|
||||
{
|
||||
if (strcmp(token, l->name) == 0)
|
||||
{
|
||||
|
@ -89,9 +90,9 @@ void activateLocations(char *locations)
|
|||
void createChristabelLocation(void)
|
||||
{
|
||||
Location *l;
|
||||
Entity *e;
|
||||
Entity *e;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (strcmp(e->name, "Christabel") == 0)
|
||||
{
|
||||
|
@ -116,7 +117,7 @@ void createChristabelLocation(void)
|
|||
|
||||
void loadLocations(cJSON *node)
|
||||
{
|
||||
int active;
|
||||
int active;
|
||||
Location *l;
|
||||
|
||||
if (node)
|
||||
|
|
|
@ -19,23 +19,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "messageBox.h"
|
||||
#include "../system/text.h"
|
||||
|
||||
#include "../system/sound.h"
|
||||
#include "../system/text.h"
|
||||
#include "messageBox.h"
|
||||
|
||||
#define MSG_BOX_TEXT_WIDTH 600
|
||||
#define MSG_BOX_TEXT_WIDTH 600
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Entity *player;
|
||||
|
||||
static void calculateMessageBoxHeight(MessageBox *msg);
|
||||
static void nextMessage(void);
|
||||
|
||||
static MessageBox head;
|
||||
static MessageBox head;
|
||||
static MessageBox *tail;
|
||||
static Entity *lastWingmate;
|
||||
static Entity *lastWingmate;
|
||||
|
||||
void initMessageBox(void)
|
||||
{
|
||||
|
@ -48,8 +49,8 @@ void initMessageBox(void)
|
|||
void addMessageBox(char *title, char *body, int type)
|
||||
{
|
||||
MessageBox *msg;
|
||||
int isFirst;
|
||||
float time;
|
||||
int isFirst;
|
||||
float time;
|
||||
|
||||
isFirst = (tail == &head);
|
||||
|
||||
|
@ -129,7 +130,7 @@ int showingMessageBoxes(void)
|
|||
void drawMessageBox(void)
|
||||
{
|
||||
MessageBox *msg = head.next;
|
||||
SDL_Rect r;
|
||||
SDL_Rect r;
|
||||
|
||||
if (msg && msg->time > 0)
|
||||
{
|
||||
|
@ -183,7 +184,7 @@ void drawMessageBox(void)
|
|||
static void nextMessage(void)
|
||||
{
|
||||
Entity *e, *wingmate;
|
||||
int isWingmate;
|
||||
int isWingmate;
|
||||
|
||||
wingmate = NULL;
|
||||
|
||||
|
@ -191,7 +192,7 @@ static void nextMessage(void)
|
|||
|
||||
playSound(SND_RADIO);
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->active && e != player)
|
||||
{
|
||||
|
@ -201,7 +202,7 @@ static void nextMessage(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (isWingmate && e->side == player->side && e->type == ET_FIGHTER && e->speed > 0)
|
||||
if (isWingmate && e->side == player->side && e->type == ET_FIGHTER && e->speed > 0)
|
||||
{
|
||||
wingmate = e;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
void resetMessageBox(void);
|
||||
void drawMessageBox(void);
|
||||
int showingMessageBoxes(void);
|
||||
int showingMessageBoxes(void);
|
||||
void doMessageBox(void);
|
||||
void addMessageBox(char *title, char *body, int type);
|
||||
void initMessageBox(void);
|
||||
|
|
|
@ -19,23 +19,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "mine.h"
|
||||
|
||||
#include "../battle/effects.h"
|
||||
#include "../battle/entities.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/util.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../battle/entities.h"
|
||||
#include "mine.h"
|
||||
|
||||
#define DAMAGE_RANGE 250
|
||||
#define SYSTEM_POWER 50
|
||||
#define TRIGGER_RANGE 150
|
||||
#define DAMAGE_RANGE 250
|
||||
#define SYSTEM_POWER 50
|
||||
#define TRIGGER_RANGE 150
|
||||
|
||||
extern Battle battle;
|
||||
extern Battle battle;
|
||||
extern Entity *player;
|
||||
extern Entity *self;
|
||||
|
||||
|
@ -68,7 +69,7 @@ Entity *spawnMine(int type)
|
|||
mine->texture = (type == ET_MINE) ? mineNormal : shadowMine;
|
||||
mine->action = think;
|
||||
mine->die = die;
|
||||
mine->flags = EF_TAKES_DAMAGE+EF_NO_PLAYER_TARGET+EF_SHORT_RADAR_RANGE+EF_NON_SOLID+EF_NO_HEALTH_BAR;
|
||||
mine->flags = EF_TAKES_DAMAGE + EF_NO_PLAYER_TARGET + EF_SHORT_RADAR_RANGE + EF_NON_SOLID + EF_NO_HEALTH_BAR;
|
||||
|
||||
if (type == ET_SHADOW_MINE)
|
||||
{
|
||||
|
@ -117,11 +118,11 @@ static void think(void)
|
|||
static void lookForFighters(void)
|
||||
{
|
||||
Entity *e, **candidates;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
candidates = getAllEntsInRadius(self->x, self->y, DAMAGE_RANGE, self);
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if (e->side != self->side && e->health > 0 && e->type == ET_FIGHTER && getDistance(self->x, self->y, e->x, e->y) <= TRIGGER_RANGE)
|
||||
{
|
||||
|
@ -142,7 +143,7 @@ static void lookForFighters(void)
|
|||
static void lookForPlayer(void)
|
||||
{
|
||||
float dx, dy, norm;
|
||||
int distance;
|
||||
int distance;
|
||||
|
||||
if (player->alive == ALIVE_ALIVE)
|
||||
{
|
||||
|
@ -216,14 +217,14 @@ static void die(void)
|
|||
static void doSplashDamage(void)
|
||||
{
|
||||
Entity *e, **candidates;
|
||||
int i, dist, kills;
|
||||
float damage, percent;
|
||||
int i, dist, kills;
|
||||
float damage, percent;
|
||||
|
||||
candidates = getAllEntsInRadius(self->x, self->y, DAMAGE_RANGE, self);
|
||||
|
||||
kills = 0;
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if (e->health > 0 && (e->type == ET_FIGHTER || e->type == ET_MINE) && !(e->flags & EF_IMMORTAL))
|
||||
{
|
||||
|
|
|
@ -19,18 +19,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "missionInfo.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/util.h"
|
||||
#include "../challenges/challenges.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/atlas.h"
|
||||
|
||||
extern App app;
|
||||
#include "../challenges/challenges.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "missionInfo.h"
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Game game;
|
||||
extern Game game;
|
||||
|
||||
static void drawMissionSummary(AtlasImage *title);
|
||||
static void drawObjectives(void);
|
||||
|
@ -42,9 +43,9 @@ static AtlasImage *missionCompleteTexture;
|
|||
static AtlasImage *missionFailedTexture;
|
||||
static AtlasImage *timeUpTexture;
|
||||
static const char *objectiveStatus[OS_MAX];
|
||||
static char *OBJECTIVES_TEXT;
|
||||
static char *NONE_TEXT;
|
||||
static char *TIME_LIMIT_TEXT;
|
||||
static char *OBJECTIVES_TEXT;
|
||||
static char *NONE_TEXT;
|
||||
static char *TIME_LIMIT_TEXT;
|
||||
|
||||
void initMissionInfo(void)
|
||||
{
|
||||
|
@ -138,14 +139,14 @@ static void drawMissionSummary(AtlasImage *header)
|
|||
static void drawObjectives(void)
|
||||
{
|
||||
Objective *o;
|
||||
SDL_Color color;
|
||||
int y = 215;
|
||||
SDL_Color color;
|
||||
int y = 215;
|
||||
|
||||
drawText(UI_WIDTH / 2, y, 28, TA_CENTER, colors.white, OBJECTIVES_TEXT);
|
||||
|
||||
y += 10;
|
||||
|
||||
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
|
||||
for (o = battle.objectiveHead.next; o != NULL; o = o->next)
|
||||
{
|
||||
if (o->active)
|
||||
{
|
||||
|
@ -189,24 +190,24 @@ static void drawObjectives(void)
|
|||
|
||||
static void drawChallenges(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Challenge *c;
|
||||
char *challengeStatus;
|
||||
SDL_Color color;
|
||||
int y = 215;
|
||||
char *challengeStatus;
|
||||
SDL_Color color;
|
||||
int y = 215;
|
||||
|
||||
drawText(UI_WIDTH / 2, y, 24, TA_CENTER, colors.white, game.currentMission->description);
|
||||
|
||||
if (battle.status == MS_START && game.currentMission->challengeData.timeLimit)
|
||||
{
|
||||
y+= 50;
|
||||
y += 50;
|
||||
|
||||
drawText(UI_WIDTH / 2, y, 20, TA_CENTER, colors.white, TIME_LIMIT_TEXT, timeToString(game.currentMission->challengeData.timeLimit, 0));
|
||||
}
|
||||
|
||||
y += 25;
|
||||
|
||||
for (i = 0 ; i < MAX_CHALLENGES ; i++)
|
||||
for (i = 0; i < MAX_CHALLENGES; i++)
|
||||
{
|
||||
c = game.currentMission->challengeData.challenges[i];
|
||||
|
||||
|
@ -224,7 +225,7 @@ static void drawChallenges(void)
|
|||
|
||||
challengeStatus = _("Complete");
|
||||
}
|
||||
else if (battle.status == MS_COMPLETE ||battle.status == MS_FAILED)
|
||||
else if (battle.status == MS_COMPLETE || battle.status == MS_FAILED)
|
||||
{
|
||||
color = colors.red;
|
||||
|
||||
|
|
|
@ -19,14 +19,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "objectives.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../galaxy/mission.h"
|
||||
|
||||
#include "../battle/hud.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/util.h"
|
||||
#include "objectives.h"
|
||||
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
|
@ -35,15 +36,15 @@ static int fireObjectivesComplete;
|
|||
|
||||
void doObjectives(void)
|
||||
{
|
||||
int objectiveFailed;
|
||||
int hasHidden;
|
||||
int objectiveFailed;
|
||||
int hasHidden;
|
||||
Objective *o;
|
||||
|
||||
battle.numObjectivesComplete = battle.numObjectivesTotal = battle.numConditions = 0;
|
||||
objectiveFailed = 0;
|
||||
hasHidden = 0;
|
||||
|
||||
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
|
||||
for (o = battle.objectiveHead.next; o != NULL; o = o->next)
|
||||
{
|
||||
if (o->active)
|
||||
{
|
||||
|
@ -116,7 +117,7 @@ void doObjectives(void)
|
|||
void updateObjective(char *name, int type)
|
||||
{
|
||||
Objective *o;
|
||||
int completed, hasHidden;
|
||||
int completed, hasHidden;
|
||||
|
||||
if (strlen(name))
|
||||
{
|
||||
|
@ -124,7 +125,7 @@ void updateObjective(char *name, int type)
|
|||
|
||||
hasHidden = 0;
|
||||
|
||||
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
|
||||
for (o = battle.objectiveHead.next; o != NULL; o = o->next)
|
||||
{
|
||||
if (o->active && o->status != OS_COMPLETE)
|
||||
{
|
||||
|
@ -178,7 +179,7 @@ void adjustObjectiveTargetValue(char *name, int type, int amount)
|
|||
{
|
||||
Objective *o;
|
||||
|
||||
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
|
||||
for (o = battle.objectiveHead.next; o != NULL; o = o->next)
|
||||
{
|
||||
if (o->active && !o->isCondition && o->targetType == type && o->currentValue < o->targetValue && strcmp(o->targetName, name) == 0)
|
||||
{
|
||||
|
@ -203,7 +204,7 @@ void updateCondition(char *name, int type)
|
|||
|
||||
if (strlen(name))
|
||||
{
|
||||
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
|
||||
for (o = battle.objectiveHead.next; o != NULL; o = o->next)
|
||||
{
|
||||
if (o->active && o->isCondition && o->targetType == type && o->currentValue < o->targetValue && strcmp(o->targetName, name) == 0)
|
||||
{
|
||||
|
@ -228,7 +229,7 @@ void completeAllObjectives(void)
|
|||
{
|
||||
Objective *o;
|
||||
|
||||
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
|
||||
for (o = battle.objectiveHead.next; o != NULL; o = o->next)
|
||||
{
|
||||
o->status = OS_COMPLETE;
|
||||
}
|
||||
|
@ -238,7 +239,7 @@ void completeConditions(void)
|
|||
{
|
||||
Objective *o;
|
||||
|
||||
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
|
||||
for (o = battle.objectiveHead.next; o != NULL; o = o->next)
|
||||
{
|
||||
if (o->isCondition)
|
||||
{
|
||||
|
@ -253,7 +254,7 @@ void failIncompleteObjectives(void)
|
|||
{
|
||||
Objective *o;
|
||||
|
||||
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
|
||||
for (o = battle.objectiveHead.next; o != NULL; o = o->next)
|
||||
{
|
||||
if (o->status != OS_COMPLETE)
|
||||
{
|
||||
|
@ -264,9 +265,9 @@ void failIncompleteObjectives(void)
|
|||
|
||||
void activateObjectives(char *objectives)
|
||||
{
|
||||
char *token;
|
||||
char *token;
|
||||
Objective *o;
|
||||
int activated;
|
||||
int activated;
|
||||
|
||||
activated = 0;
|
||||
|
||||
|
@ -274,7 +275,7 @@ void activateObjectives(char *objectives)
|
|||
|
||||
while (token)
|
||||
{
|
||||
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
|
||||
for (o = battle.objectiveHead.next; o != NULL; o = o->next)
|
||||
{
|
||||
if (strcmp(token, o->id) == 0)
|
||||
{
|
||||
|
@ -343,7 +344,7 @@ void loadObjectives(cJSON *node)
|
|||
void addEpicLivesObjective(void)
|
||||
{
|
||||
Objective *o;
|
||||
char id[MAX_DESCRIPTION_LENGTH];
|
||||
char id[MAX_DESCRIPTION_LENGTH];
|
||||
|
||||
o = malloc(sizeof(Objective));
|
||||
memset(o, 0, sizeof(Objective));
|
||||
|
@ -364,7 +365,7 @@ void addEpicLivesObjective(void)
|
|||
void addEpicKillsObjective(void)
|
||||
{
|
||||
Objective *o;
|
||||
char id[MAX_DESCRIPTION_LENGTH];
|
||||
char id[MAX_DESCRIPTION_LENGTH];
|
||||
|
||||
o = malloc(sizeof(Objective));
|
||||
memset(o, 0, sizeof(Objective));
|
||||
|
|
|
@ -19,30 +19,31 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "player.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/controls.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../battle/hud.h"
|
||||
#include "../battle/objectives.h"
|
||||
|
||||
#include "../battle/bullets.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../battle/hud.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/controls.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/util.h"
|
||||
#include "player.h"
|
||||
|
||||
#define MAX_SELECTABLE_PLAYERS 8
|
||||
#define MAX_SELECTABLE_TARGETS 8
|
||||
#define MAX_SELECTABLE_PLAYERS 8
|
||||
#define MAX_SELECTABLE_TARGETS 8
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Dev dev;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Dev dev;
|
||||
extern Entity *player;
|
||||
extern Entity *self;
|
||||
extern Game game;
|
||||
extern Game game;
|
||||
|
||||
static void selectTarget(void);
|
||||
static void switchGuns(void);
|
||||
|
@ -58,15 +59,15 @@ static void faceMouse(void);
|
|||
static void handleMouse(void);
|
||||
static void preFireMissile(void);
|
||||
static void applyRestrictions(void);
|
||||
static int isPriorityMissionTarget(Entity *e, int dist, int closest);
|
||||
static int targetOutOfRange(void);
|
||||
static int isPriorityMissionTarget(Entity *e, int dist, int closest);
|
||||
static int targetOutOfRange(void);
|
||||
static void rechargeBoostECM(void);
|
||||
static void setPilotName(void);
|
||||
static void updateDeathStats(void);
|
||||
static void handleSuspicionLevel(void);
|
||||
|
||||
static int selectedPlayerIndex;
|
||||
static int availableGuns[BT_MAX];
|
||||
static int selectedPlayerIndex;
|
||||
static int availableGuns[BT_MAX];
|
||||
static Entity *availablePlayerUnits[MAX_SELECTABLE_PLAYERS];
|
||||
|
||||
void initPlayer(void)
|
||||
|
@ -81,7 +82,7 @@ void initPlayer(void)
|
|||
|
||||
if (!player->combinedGuns)
|
||||
{
|
||||
for (i = 0 ; i < MAX_FIGHTER_GUNS ; i++)
|
||||
for (i = 0; i < MAX_FIGHTER_GUNS; i++)
|
||||
{
|
||||
n = player->guns[i].type;
|
||||
|
||||
|
@ -129,7 +130,7 @@ static void setPilotName(void)
|
|||
|
||||
pos = -1;
|
||||
|
||||
for (i = 0 ; i < strlen(game.currentMission->pilot) ; i++)
|
||||
for (i = 0; i < strlen(game.currentMission->pilot); i++)
|
||||
{
|
||||
if (game.currentMission->pilot[i] == ' ')
|
||||
{
|
||||
|
@ -465,13 +466,13 @@ static void initPlayerSelect(void)
|
|||
{
|
||||
Entity *e;
|
||||
|
||||
memset(&availablePlayerUnits, 0, sizeof(Entity*) * MAX_SELECTABLE_PLAYERS);
|
||||
memset(&availablePlayerUnits, 0, sizeof(Entity *) * MAX_SELECTABLE_PLAYERS);
|
||||
|
||||
selectedPlayerIndex = 0;
|
||||
|
||||
if (battle.epicLives == 0 || (battle.epicLives > 0 && --battle.epicLives > 0))
|
||||
{
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->active && e->type == ET_FIGHTER && e->health > 0 && e->side == SIDE_ALLIES && selectedPlayerIndex < MAX_SELECTABLE_PLAYERS)
|
||||
{
|
||||
|
@ -536,8 +537,7 @@ static void selectNewPlayer(int dir)
|
|||
selectedPlayerIndex = mod(selectedPlayerIndex, MAX_SELECTABLE_PLAYERS);
|
||||
|
||||
player = availablePlayerUnits[selectedPlayerIndex];
|
||||
}
|
||||
while (player == NULL);
|
||||
} while (player == NULL);
|
||||
|
||||
battle.camera.x = player->x - (app.winWidth / 2);
|
||||
battle.camera.y = player->y - (app.winHeight / 2);
|
||||
|
@ -596,8 +596,7 @@ static void switchGuns(void)
|
|||
do
|
||||
{
|
||||
i = (i + 1) % BT_MAX;
|
||||
}
|
||||
while (!availableGuns[i]);
|
||||
} while (!availableGuns[i]);
|
||||
}
|
||||
|
||||
if (player->selectedGunType != i)
|
||||
|
@ -611,20 +610,20 @@ static void selectTarget(void)
|
|||
{
|
||||
unsigned int closest = MAX_TARGET_RANGE;
|
||||
unsigned int dist = MAX_TARGET_RANGE;
|
||||
int i, total;
|
||||
Entity *e, *near;
|
||||
Entity *targets[MAX_SELECTABLE_TARGETS];
|
||||
int i, total;
|
||||
Entity *e, *near;
|
||||
Entity *targets[MAX_SELECTABLE_TARGETS];
|
||||
|
||||
i = 0;
|
||||
near = NULL;
|
||||
memset(targets, 0, sizeof(Entity*) * MAX_SELECTABLE_TARGETS);
|
||||
memset(targets, 0, sizeof(Entity *) * MAX_SELECTABLE_TARGETS);
|
||||
|
||||
if (player->target && (!player->target->health || !player->target->systemPower))
|
||||
{
|
||||
player->target = NULL;
|
||||
}
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->active && e != player && (e->flags & EF_TAKES_DAMAGE) && (!(e->flags & EF_NO_PLAYER_TARGET)) && e->side != player->side && e->alive == ALIVE_ALIVE && e->systemPower > 0 && i < MAX_SELECTABLE_TARGETS)
|
||||
{
|
||||
|
@ -649,7 +648,7 @@ static void selectTarget(void)
|
|||
|
||||
total = i;
|
||||
|
||||
for (i = 0 ; i < total ; i++)
|
||||
for (i = 0; i < total; i++)
|
||||
{
|
||||
if (targets[i] == player->target)
|
||||
{
|
||||
|
@ -675,11 +674,11 @@ static void selectMissionTarget(void)
|
|||
{
|
||||
unsigned int closest = MAX_TARGET_RANGE;
|
||||
unsigned int dist = MAX_TARGET_RANGE;
|
||||
Entity *e;
|
||||
Entity *e;
|
||||
|
||||
battle.missionTarget = NULL;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->active && e->flags & EF_MISSION_TARGET && e->alive == ALIVE_ALIVE)
|
||||
{
|
||||
|
@ -755,7 +754,7 @@ void setInitialPlayerAngle(void)
|
|||
}
|
||||
}
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->side == player->side)
|
||||
{
|
||||
|
@ -788,8 +787,8 @@ static void handleSuspicionLevel(void)
|
|||
void loadPlayer(cJSON *node)
|
||||
{
|
||||
char *type;
|
||||
int side, addFlags;
|
||||
long flags;
|
||||
int side, addFlags;
|
||||
long flags;
|
||||
|
||||
type = cJSON_GetObjectItem(node, "type")->valuestring;
|
||||
side = lookup(cJSON_GetObjectItem(node, "side")->valuestring);
|
||||
|
|
|
@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
void loadPlayer(struct cJSON *node);
|
||||
int playerHasGun(int type);
|
||||
int playerHasGun(int type);
|
||||
void setInitialPlayerAngle(void);
|
||||
void doPlayerSelect(void);
|
||||
void doPlayer(void);
|
||||
|
|
|
@ -19,21 +19,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "quadtree.h"
|
||||
#include "../system/util.h"
|
||||
|
||||
#define QT_INITIAL_CAPACITY 8
|
||||
#define QT_MAX_DEPTH 5
|
||||
#include "../system/util.h"
|
||||
#include "quadtree.h"
|
||||
|
||||
#define QT_INITIAL_CAPACITY 8
|
||||
#define QT_MAX_DEPTH 5
|
||||
|
||||
extern Battle battle;
|
||||
|
||||
static Entity **candidates;
|
||||
static int cIndex;
|
||||
static int cCapacity;
|
||||
static int cIndex;
|
||||
static int cCapacity;
|
||||
|
||||
static int getIndex(Quadtree *root, int x, int y, int w, int h);
|
||||
static int getIndex(Quadtree *root, int x, int y, int w, int h);
|
||||
static void removeEntity(Entity *e, Quadtree *root);
|
||||
static int candidatesComparator(const void *a, const void *b);
|
||||
static int candidatesComparator(const void *a, const void *b);
|
||||
static void getAllEntsWithinNode(int x, int y, int w, int h, Entity *ignore, Quadtree *root);
|
||||
static void destroyQuadtreeNode(Quadtree *root);
|
||||
static void resizeQTEntCapacity(Quadtree *root);
|
||||
|
@ -42,7 +43,7 @@ static void resizeCandidates(void);
|
|||
void initQuadtree(Quadtree *root)
|
||||
{
|
||||
Quadtree *node;
|
||||
int i, w, h;
|
||||
int i, w, h;
|
||||
|
||||
/* entire battlefield */
|
||||
if (root->depth == 0)
|
||||
|
@ -50,13 +51,13 @@ void initQuadtree(Quadtree *root)
|
|||
root->w = BATTLE_AREA_WIDTH;
|
||||
root->h = BATTLE_AREA_HEIGHT;
|
||||
root->capacity = QT_INITIAL_CAPACITY;
|
||||
root->ents = malloc(sizeof(Entity*) * root->capacity);
|
||||
memset(root->ents, 0, sizeof(Entity*) * root->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);
|
||||
candidates = malloc(sizeof(Entity *) * cCapacity);
|
||||
memset(candidates, 0, sizeof(Entity *) * cCapacity);
|
||||
}
|
||||
|
||||
w = root->w / 2;
|
||||
|
@ -64,7 +65,7 @@ void initQuadtree(Quadtree *root)
|
|||
|
||||
if (root->depth + 1 < QT_MAX_DEPTH)
|
||||
{
|
||||
for (i = 0 ; i < 4 ; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
node = malloc(sizeof(Quadtree));
|
||||
memset(node, 0, sizeof(Quadtree));
|
||||
|
@ -72,8 +73,8 @@ void initQuadtree(Quadtree *root)
|
|||
|
||||
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);
|
||||
node->ents = malloc(sizeof(Entity *) * node->capacity);
|
||||
memset(node->ents, 0, sizeof(Entity *) * node->capacity);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
|
@ -142,7 +143,7 @@ static void resizeQTEntCapacity(Quadtree *root)
|
|||
|
||||
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->ents = resize(root->ents, sizeof(Entity *) * root->capacity, sizeof(Entity *) * n);
|
||||
root->capacity = n;
|
||||
}
|
||||
|
||||
|
@ -218,7 +219,7 @@ static void removeEntity(Entity *e, Quadtree *root)
|
|||
|
||||
n = root->numEnts;
|
||||
|
||||
for (i = 0 ; i < root->capacity ; i++)
|
||||
for (i = 0; i < root->capacity; i++)
|
||||
{
|
||||
if (root->ents[i] == e)
|
||||
{
|
||||
|
@ -227,13 +228,13 @@ static void removeEntity(Entity *e, Quadtree *root)
|
|||
}
|
||||
}
|
||||
|
||||
qsort(root->ents, n, sizeof(Entity*), candidatesComparator);
|
||||
qsort(root->ents, n, sizeof(Entity *), candidatesComparator);
|
||||
}
|
||||
|
||||
Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore)
|
||||
{
|
||||
cIndex = 0;
|
||||
memset(candidates, 0, sizeof(Entity*) * cCapacity);
|
||||
memset(candidates, 0, sizeof(Entity *) * cCapacity);
|
||||
|
||||
getAllEntsWithinNode(x, y, w, h, ignore, &battle.quadtree);
|
||||
|
||||
|
@ -261,14 +262,14 @@ static void getAllEntsWithinNode(int x, int y, int w, int h, Entity *ignore, Qua
|
|||
}
|
||||
else
|
||||
{
|
||||
for (i = 0 ; i < 4 ; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
getAllEntsWithinNode(x, y, w, h, ignore, root->node[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0 ; i < root->numEnts ; i++)
|
||||
for (i = 0; i < root->numEnts; i++)
|
||||
{
|
||||
candidates[cIndex++] = root->ents[i];
|
||||
|
||||
|
@ -288,7 +289,7 @@ static void resizeCandidates(void)
|
|||
|
||||
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);
|
||||
candidates = resize(candidates, sizeof(Entity *) * cCapacity, sizeof(Entity *) * n);
|
||||
cCapacity = n;
|
||||
}
|
||||
|
||||
|
@ -314,7 +315,7 @@ static void destroyQuadtreeNode(Quadtree *root)
|
|||
|
||||
if (root->node[0])
|
||||
{
|
||||
for (i = 0 ; i < 4 ; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
destroyQuadtreeNode(root->node[i]);
|
||||
|
||||
|
@ -327,18 +328,18 @@ static void destroyQuadtreeNode(Quadtree *root)
|
|||
|
||||
static int candidatesComparator(const void *a, const void *b)
|
||||
{
|
||||
Entity *e1 = *((Entity**)a);
|
||||
Entity *e2 = *((Entity**)b);
|
||||
Entity *e1 = *((Entity **)a);
|
||||
Entity *e2 = *((Entity **)b);
|
||||
|
||||
if (!e1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (!e2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (!e2)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void destroyQuadtree(void);
|
||||
void destroyQuadtree(void);
|
||||
Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore);
|
||||
Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
|
||||
void removeFromQuadtree(Entity *e, Quadtree *root);
|
||||
void addToQuadtree(Entity *e, Quadtree *root);
|
||||
void initQuadtree(Quadtree *root);
|
||||
void removeFromQuadtree(Entity *e, Quadtree *root);
|
||||
void addToQuadtree(Entity *e, Quadtree *root);
|
||||
void initQuadtree(Quadtree *root);
|
||||
|
|
|
@ -19,21 +19,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "radar.h"
|
||||
#include "../system/text.h"
|
||||
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/util.h"
|
||||
#include "radar.h"
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Entity *player;
|
||||
|
||||
static AtlasImage *radarTexture;
|
||||
static AtlasImage *radarWarningTexture;
|
||||
static int radarRanges[] = {20, 40, 60};
|
||||
static char *CAUTION_TEXT;
|
||||
static int radarRanges[] = {20, 40, 60};
|
||||
static char *CAUTION_TEXT;
|
||||
|
||||
void initRadar(void)
|
||||
{
|
||||
|
@ -49,8 +50,8 @@ void initRadar(void)
|
|||
void drawRadar(void)
|
||||
{
|
||||
SDL_Rect r;
|
||||
Entity *e;
|
||||
int dist, inRange, blink;
|
||||
Entity *e;
|
||||
int dist, inRange, blink;
|
||||
|
||||
blit(radarTexture, app.winWidth - 85, app.winHeight - 85, 1);
|
||||
|
||||
|
@ -60,7 +61,7 @@ void drawRadar(void)
|
|||
|
||||
blink = battle.stats[STAT_TIME] % 60 < 30;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
dist = getDistance(e->x, e->y, player->x, player->y);
|
||||
|
||||
|
|
|
@ -19,31 +19,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "rope.h"
|
||||
|
||||
#include "../battle/hud.h"
|
||||
#include "../battle/quadtree.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/util.h"
|
||||
#include "rope.h"
|
||||
|
||||
#define ROPE_DISTANCE 128
|
||||
#define ROPE_DISTANCE 128
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Entity *player;
|
||||
extern Entity *self;
|
||||
|
||||
void attachRope(void)
|
||||
{
|
||||
int i, distance;
|
||||
int i, distance;
|
||||
Entity *e, **candidates;
|
||||
|
||||
if ((self->flags & EF_HAS_ROPE) && self->towing == NULL)
|
||||
{
|
||||
candidates = getAllEntsInRadius(self->x, self->y, self->separationRadius, self);
|
||||
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
for (i = 0, e = candidates[i]; e != NULL; e = candidates[++i])
|
||||
{
|
||||
if (!e->owner && e->type == ET_FIGHTER && (e->flags & EF_DISABLED) && (e->flags & EF_ROPED_ATTACHED) == 0 && e->alive == ALIVE_ALIVE)
|
||||
{
|
||||
|
@ -77,7 +78,7 @@ void attachRope(void)
|
|||
void doRope(Entity *owner)
|
||||
{
|
||||
float dx, dy, angle, force;
|
||||
int distance;
|
||||
int distance;
|
||||
|
||||
if (owner->towing)
|
||||
{
|
||||
|
|
|
@ -19,28 +19,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "script.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../battle/locations.h"
|
||||
|
||||
#include "../battle/entities.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../battle/hud.h"
|
||||
#include "../battle/jumpgate.h"
|
||||
#include "../battle/locations.h"
|
||||
#include "../battle/messageBox.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/spawners.h"
|
||||
#include "../battle/waypoints.h"
|
||||
#include "../battle/messageBox.h"
|
||||
#include "../battle/entities.h"
|
||||
#include "../battle/jumpgate.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "script.h"
|
||||
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
|
||||
static void executeNextLine(ScriptRunner *runner);
|
||||
|
||||
static cJSON *scriptJSON, *rootJSON;
|
||||
static ScriptRunner head;
|
||||
static cJSON *scriptJSON, *rootJSON;
|
||||
static ScriptRunner head;
|
||||
static ScriptRunner *tail;
|
||||
static int runScript;
|
||||
static int runScript;
|
||||
|
||||
void initScript(cJSON *root)
|
||||
{
|
||||
|
@ -78,7 +79,7 @@ void doScript(void)
|
|||
{
|
||||
prev = &head;
|
||||
|
||||
for (runner = head.next ; runner != NULL ; runner = runner->next)
|
||||
for (runner = head.next; runner != NULL; runner = runner->next)
|
||||
{
|
||||
runner->delay = MAX(0, runner->delay - 1);
|
||||
|
||||
|
@ -112,10 +113,10 @@ void doScript(void)
|
|||
void runScriptFunction(const char *format, ...)
|
||||
{
|
||||
ScriptRunner *scriptRunner;
|
||||
cJSON *function;
|
||||
char *functionName;
|
||||
char funcNameBuffer[MAX_NAME_LENGTH];
|
||||
va_list args;
|
||||
cJSON *function;
|
||||
char *functionName;
|
||||
char funcNameBuffer[MAX_NAME_LENGTH];
|
||||
va_list args;
|
||||
|
||||
if (scriptJSON && runScript)
|
||||
{
|
||||
|
@ -154,9 +155,9 @@ void runScriptFunction(const char *format, ...)
|
|||
static void executeNextLine(ScriptRunner *runner)
|
||||
{
|
||||
char *line;
|
||||
char command[32];
|
||||
char strParam[3][256];
|
||||
int intParam[2];
|
||||
char command[32];
|
||||
char strParam[3][256];
|
||||
int intParam[2];
|
||||
|
||||
line = runner->line->valuestring;
|
||||
|
||||
|
|
|
@ -19,24 +19,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "spawners.h"
|
||||
#include "../json/cJSON.h"
|
||||
|
||||
#include "../battle/fighters.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/util.h"
|
||||
#include "spawners.h"
|
||||
|
||||
extern Battle battle;
|
||||
extern Battle battle;
|
||||
extern Entity *player;
|
||||
|
||||
void doSpawners(void)
|
||||
{
|
||||
Entity *e;
|
||||
Entity *e;
|
||||
Spawner *s;
|
||||
char *type;
|
||||
int i, num, addFlags, addAIFlags;
|
||||
long flags, aiFlags;
|
||||
char *type;
|
||||
int i, num, addFlags, addAIFlags;
|
||||
long flags, aiFlags;
|
||||
|
||||
for (s = battle.spawnerHead.next ; s != NULL ; s = s->next)
|
||||
for (s = battle.spawnerHead.next; s != NULL; s = s->next)
|
||||
{
|
||||
if (s->active && --s->time <= 0)
|
||||
{
|
||||
|
@ -66,7 +67,7 @@ void doSpawners(void)
|
|||
aiFlags = flagsToLong(s->aiFlags, &addAIFlags);
|
||||
}
|
||||
|
||||
for (i = 0 ; i < num ; i++)
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
type = s->types[rand() % s->numTypes];
|
||||
|
||||
|
@ -122,7 +123,7 @@ void activateSpawner(char *name, int active)
|
|||
{
|
||||
Spawner *s;
|
||||
|
||||
for (s = battle.spawnerHead.next ; s != NULL ; s = s->next)
|
||||
for (s = battle.spawnerHead.next; s != NULL; s = s->next)
|
||||
{
|
||||
if (strcmp(s->name, name) == 0)
|
||||
{
|
||||
|
@ -134,7 +135,7 @@ void activateSpawner(char *name, int active)
|
|||
void activateTrespasserSpawner(void)
|
||||
{
|
||||
Spawner *s;
|
||||
char types[MAX_DESCRIPTION_LENGTH];
|
||||
char types[MAX_DESCRIPTION_LENGTH];
|
||||
|
||||
s = malloc(sizeof(Spawner));
|
||||
memset(s, 0, sizeof(Spawner));
|
||||
|
|
|
@ -19,8 +19,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "starfield.h"
|
||||
|
||||
#include "../system/util.h"
|
||||
#include "starfield.h"
|
||||
|
||||
extern App app;
|
||||
|
||||
|
@ -32,7 +33,7 @@ void initStars(void)
|
|||
|
||||
memset(stars, 0, sizeof(Star) * MAX_STARS);
|
||||
|
||||
for (i = 0 ; i < MAX_STARS ; i++)
|
||||
for (i = 0; i < MAX_STARS; i++)
|
||||
{
|
||||
stars[i].x = rand() % app.winWidth;
|
||||
stars[i].y = rand() % app.winHeight;
|
||||
|
@ -46,7 +47,7 @@ void doStars(float dx, float dy)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < MAX_STARS ; i++)
|
||||
for (i = 0; i < MAX_STARS; i++)
|
||||
{
|
||||
stars[i].x -= (dx * stars[i].speed);
|
||||
stars[i].y -= (dy * stars[i].speed);
|
||||
|
@ -61,7 +62,7 @@ void drawStars(void)
|
|||
int i;
|
||||
int c;
|
||||
|
||||
for (i = 0 ; i < MAX_STARS ; i++)
|
||||
for (i = 0; i < MAX_STARS; i++)
|
||||
{
|
||||
c = 64 * stars[i].speed;
|
||||
|
||||
|
|
|
@ -19,24 +19,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "waypoints.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/sound.h"
|
||||
|
||||
#include "../battle/entities.h"
|
||||
#include "../battle/hud.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../battle/entities.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/util.h"
|
||||
#include "waypoints.h"
|
||||
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Entity *player;
|
||||
extern Entity *self;
|
||||
extern Game game;
|
||||
extern Game game;
|
||||
|
||||
static void think(void);
|
||||
static int teamMatesClose(void);
|
||||
static int isCurrentObjective(void);
|
||||
static int teamMatesClose(void);
|
||||
static int isCurrentObjective(void);
|
||||
|
||||
static int waypointId;
|
||||
static int currentWaypointId;
|
||||
|
@ -57,7 +58,7 @@ Entity *spawnWaypoint(void)
|
|||
waypoint->active = 0;
|
||||
waypoint->health = waypoint->maxHealth = FPS;
|
||||
waypoint->texture = getAtlasImage("gfx/entities/waypoint.png");
|
||||
waypoint->flags = EF_NO_MT_BOX+EF_MISSION_TARGET+EF_NO_HEALTH_BAR;
|
||||
waypoint->flags = EF_NO_MT_BOX + EF_MISSION_TARGET + EF_NO_HEALTH_BAR;
|
||||
waypoint->action = think;
|
||||
|
||||
waypoint->w = waypoint->texture->rect.w;
|
||||
|
@ -128,7 +129,7 @@ static int teamMatesClose(void)
|
|||
|
||||
if (player->side != SIDE_PANDORAN)
|
||||
{
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->active && e->type == ET_FIGHTER && e->side == SIDE_ALLIES)
|
||||
{
|
||||
|
@ -152,7 +153,7 @@ void activateNextWaypoint(void)
|
|||
|
||||
currentWaypointId++;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->type == ET_WAYPOINT && e->id == currentWaypointId)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void activateNextWaypoint(void);
|
||||
void activateNextWaypoint(void);
|
||||
Entity *spawnWaypoint(void);
|
||||
void resetWaypoints(void);
|
||||
void resetWaypoints(void);
|
||||
|
|
|
@ -19,83 +19,84 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "challengeHome.h"
|
||||
#include "../battle/starfield.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/input.h"
|
||||
#include "../game/title.h"
|
||||
#include "../game/stats.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../game/options.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../game/fighterDatabase.h"
|
||||
#include "../system/transition.h"
|
||||
#include "../challenges/challenges.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/draw.h"
|
||||
|
||||
#include "../battle/battle.h"
|
||||
#include "../battle/starfield.h"
|
||||
#include "../challenges/challenges.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../game/fighterDatabase.h"
|
||||
#include "../game/options.h"
|
||||
#include "../game/stats.h"
|
||||
#include "../game/title.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/input.h"
|
||||
#include "../system/resources.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/textures.h"
|
||||
#include "../system/transition.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "challengeHome.h"
|
||||
|
||||
#define CHALLENGES_PER_PAGE 14
|
||||
#define SHOW_CHALLENGES 0
|
||||
#define SHOW_FIGHTER_DB 5
|
||||
#define SHOW_MENU 1
|
||||
#define SHOW_OPTIONS 2
|
||||
#define SHOW_STATS 3
|
||||
#define SHOW_TROPHIES 4
|
||||
#define CHALLENGES_PER_PAGE 14
|
||||
#define SHOW_CHALLENGES 0
|
||||
#define SHOW_FIGHTER_DB 5
|
||||
#define SHOW_MENU 1
|
||||
#define SHOW_OPTIONS 2
|
||||
#define SHOW_STATS 3
|
||||
#define SHOW_TROPHIES 4
|
||||
|
||||
extern App app;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Dev dev;
|
||||
extern Game game;
|
||||
extern Dev dev;
|
||||
extern Game game;
|
||||
|
||||
static void logic(void);
|
||||
static void draw(void);
|
||||
static void handleKeyboard(void);
|
||||
static void drawChallenges(void);
|
||||
static void doChallengeList(void);
|
||||
static void startChallengeMission(void);
|
||||
static void drawMenu(void);
|
||||
static void resume(void);
|
||||
static void stats(void);
|
||||
static void trophies(void);
|
||||
static void options(void);
|
||||
static void ok(void);
|
||||
static void returnFromOptions(void);
|
||||
static void unlockChallenges(void);
|
||||
static void quit(void);
|
||||
static void updateChallengeMissionData(void);
|
||||
static void logic(void);
|
||||
static void draw(void);
|
||||
static void handleKeyboard(void);
|
||||
static void drawChallenges(void);
|
||||
static void doChallengeList(void);
|
||||
static void startChallengeMission(void);
|
||||
static void drawMenu(void);
|
||||
static void resume(void);
|
||||
static void stats(void);
|
||||
static void trophies(void);
|
||||
static void options(void);
|
||||
static void ok(void);
|
||||
static void returnFromOptions(void);
|
||||
static void unlockChallenges(void);
|
||||
static void quit(void);
|
||||
static void updateChallengeMissionData(void);
|
||||
static char *listRestrictions(void);
|
||||
static void prevPage(void);
|
||||
static void nextPage(void);
|
||||
static void fighterDatabase(void);
|
||||
static void prevPage(void);
|
||||
static void nextPage(void);
|
||||
static void fighterDatabase(void);
|
||||
|
||||
static SDL_Texture *background;
|
||||
static AtlasImage *planetTexture;
|
||||
static AtlasImage *challengeIcon;
|
||||
static AtlasImage *challengeIconHighlight;
|
||||
static Widget *start;
|
||||
static PointF planet;
|
||||
static int show;
|
||||
static int page;
|
||||
static float maxPages;
|
||||
static char timeLimit[MAX_DESCRIPTION_LENGTH];
|
||||
static char restrictions[MAX_DESCRIPTION_LENGTH];
|
||||
static int hasRestrictions;
|
||||
static Widget *prev;
|
||||
static Widget *next;
|
||||
static char *CHALLENGES_TEXT;
|
||||
static char *COMPLETED_TEXT;
|
||||
static char *PAGE_TEXT;
|
||||
static char *LOCKED_TEXT;
|
||||
static char *CRAFT_TEXT;
|
||||
static char *TIME_TEXT;
|
||||
static char *RESTRICTIONS_TEXT;
|
||||
static AtlasImage *planetTexture;
|
||||
static AtlasImage *challengeIcon;
|
||||
static AtlasImage *challengeIconHighlight;
|
||||
static Widget *start;
|
||||
static PointF planet;
|
||||
static int show;
|
||||
static int page;
|
||||
static float maxPages;
|
||||
static char timeLimit[MAX_DESCRIPTION_LENGTH];
|
||||
static char restrictions[MAX_DESCRIPTION_LENGTH];
|
||||
static int hasRestrictions;
|
||||
static Widget *prev;
|
||||
static Widget *next;
|
||||
static char *CHALLENGES_TEXT;
|
||||
static char *COMPLETED_TEXT;
|
||||
static char *PAGE_TEXT;
|
||||
static char *LOCKED_TEXT;
|
||||
static char *CRAFT_TEXT;
|
||||
static char *TIME_TEXT;
|
||||
static char *RESTRICTIONS_TEXT;
|
||||
|
||||
void initChallengeHome(void)
|
||||
{
|
||||
|
@ -132,14 +133,14 @@ void initChallengeHome(void)
|
|||
challengeIcon = getAtlasImage("gfx/challenges/challengeIcon.png");
|
||||
challengeIconHighlight = getAtlasImage("gfx/challenges/challengeIconHighlight.png");
|
||||
|
||||
battle.camera.x = battle.camera.y = 0;
|
||||
battle.camera.x = battle.camera.y = 0;
|
||||
|
||||
planet.x = rand() % app.winWidth;
|
||||
planet.y = rand() % app.winHeight;
|
||||
|
||||
maxPages = page = 0;
|
||||
|
||||
for (m = game.challengeMissionHead.next ; m != NULL ; m = m->next)
|
||||
for (m = game.challengeMissionHead.next; m != NULL; m = m->next)
|
||||
{
|
||||
maxPages++;
|
||||
}
|
||||
|
@ -213,7 +214,7 @@ static void unlockChallenges(void)
|
|||
|
||||
prevCompleted = 1;
|
||||
|
||||
for (m = game.challengeMissionHead.next ; m != NULL ; m = m->next)
|
||||
for (m = game.challengeMissionHead.next; m != NULL; m = m->next)
|
||||
{
|
||||
m->available = (prevCompleted > 0 || dev.debug);
|
||||
|
||||
|
@ -269,13 +270,13 @@ static void logic(void)
|
|||
static void doChallengeList(void)
|
||||
{
|
||||
Mission *c;
|
||||
int i, startIndex, end;
|
||||
int i, startIndex, end;
|
||||
|
||||
i = 0;
|
||||
startIndex = page * CHALLENGES_PER_PAGE;
|
||||
end = startIndex + CHALLENGES_PER_PAGE;
|
||||
|
||||
for (c = game.challengeMissionHead.next ; c != NULL ; c = c->next)
|
||||
for (c = game.challengeMissionHead.next; c != NULL; c = c->next)
|
||||
{
|
||||
if (i >= startIndex && i < end && app.mouse.button[SDL_BUTTON_LEFT] && collision(app.uiMouse.x, app.uiMouse.y, 3, 3, c->rect.x, c->rect.y, c->rect.w, c->rect.h))
|
||||
{
|
||||
|
@ -331,7 +332,7 @@ static char *listRestrictions(void)
|
|||
addRestriction(textBuffer, game.currentMission->challengeData.noBoost, _("No Boost"));
|
||||
addRestriction(textBuffer, game.currentMission->challengeData.noGuns, _("No Guns"));
|
||||
|
||||
return strlen(textBuffer) > 0 ? textBuffer : "-";
|
||||
return strlen(textBuffer) > 0 ? textBuffer : "-";
|
||||
}
|
||||
|
||||
static void draw(void)
|
||||
|
@ -390,10 +391,10 @@ static void draw(void)
|
|||
|
||||
static void drawChallenges(void)
|
||||
{
|
||||
Mission *m;
|
||||
Mission *m;
|
||||
Challenge *c;
|
||||
SDL_Rect r;
|
||||
int i, start, end;
|
||||
SDL_Rect r;
|
||||
int i, start, end;
|
||||
|
||||
r.x = 135;
|
||||
r.y = 165;
|
||||
|
@ -404,7 +405,7 @@ static void drawChallenges(void)
|
|||
|
||||
i = 0;
|
||||
|
||||
for (m = game.challengeMissionHead.next ; m != NULL ; m = m->next)
|
||||
for (m = game.challengeMissionHead.next; m != NULL; m = m->next)
|
||||
{
|
||||
m->rect = r;
|
||||
|
||||
|
|
|
@ -19,50 +19,51 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "challenges.h"
|
||||
|
||||
#include "../battle/fighters.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../game/stats.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/util.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../game/stats.h"
|
||||
#include "../system/io.h"
|
||||
#include "challenges.h"
|
||||
|
||||
extern Battle battle;
|
||||
extern Dev dev;
|
||||
extern Battle battle;
|
||||
extern Dev dev;
|
||||
extern Entity *player;
|
||||
extern Game game;
|
||||
extern Game game;
|
||||
|
||||
static void updateTimeChallenge(Challenge *c);
|
||||
static void updateSurvivalChallenge(Challenge *c);
|
||||
static void updateAccuracyChallenge(Challenge *c);
|
||||
static void updateArmourChallenge(Challenge *c);
|
||||
static void updateLossesChallenge(Challenge *c);
|
||||
static void updatePlayerKillsChallenge(Challenge *c);
|
||||
static void updateDisabledChallenge(Challenge *c);
|
||||
static void updateItemsChallenge(Challenge *c);
|
||||
static void updateSurrenderChallenge(Challenge *c);
|
||||
static void updateWaypointChallenge(Challenge *c);
|
||||
static void updateRescueChallenge(Challenge *c);
|
||||
static void completeChallenge(void);
|
||||
static void failChallenge(void);
|
||||
static int updateChallenges(void);
|
||||
static void updateTimeChallenge(Challenge *c);
|
||||
static void updateSurvivalChallenge(Challenge *c);
|
||||
static void updateAccuracyChallenge(Challenge *c);
|
||||
static void updateArmourChallenge(Challenge *c);
|
||||
static void updateLossesChallenge(Challenge *c);
|
||||
static void updatePlayerKillsChallenge(Challenge *c);
|
||||
static void updateDisabledChallenge(Challenge *c);
|
||||
static void updateItemsChallenge(Challenge *c);
|
||||
static void updateSurrenderChallenge(Challenge *c);
|
||||
static void updateWaypointChallenge(Challenge *c);
|
||||
static void updateRescueChallenge(Challenge *c);
|
||||
static void completeChallenge(void);
|
||||
static void failChallenge(void);
|
||||
static int updateChallenges(void);
|
||||
static char *getFormattedChallengeDescription(const char *format, ...);
|
||||
static int challengeFinished(void);
|
||||
static int alreadyPassed(void);
|
||||
static void printStats(void);
|
||||
static int challengeFinished(void);
|
||||
static int alreadyPassed(void);
|
||||
static void printStats(void);
|
||||
|
||||
static char descriptionBuffer[MAX_DESCRIPTION_LENGTH];
|
||||
static char descriptionBuffer[MAX_DESCRIPTION_LENGTH];
|
||||
static const char *challengeDescription[CHALLENGE_MAX];
|
||||
|
||||
void initChallenges(void)
|
||||
{
|
||||
Mission *mission, *tail;
|
||||
char **filenames;
|
||||
char path[MAX_FILENAME_LENGTH];
|
||||
int count, i;
|
||||
char **filenames;
|
||||
char path[MAX_FILENAME_LENGTH];
|
||||
int count, i;
|
||||
|
||||
challengeDescription[CHALLENGE_ARMOUR] = _("Retain at least %d%% armour");
|
||||
challengeDescription[CHALLENGE_TIME] = _("Complete challenge in %d seconds or less");
|
||||
|
@ -85,7 +86,7 @@ void initChallenges(void)
|
|||
|
||||
filenames = getFileList("data/challenges", &count);
|
||||
|
||||
for (i = 0 ; i < count ; i++)
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
sprintf(path, "data/challenges/%s", filenames[i]);
|
||||
|
||||
|
@ -105,7 +106,7 @@ void initChallenges(void)
|
|||
|
||||
void loadChallenge(Mission *mission, cJSON *node)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Challenge *challenge;
|
||||
|
||||
mission->challengeData.isChallenge = 1;
|
||||
|
@ -248,14 +249,14 @@ static int challengeFinished(void)
|
|||
|
||||
static int updateChallenges(void)
|
||||
{
|
||||
int i, numPassed;
|
||||
int i, numPassed;
|
||||
Challenge *c;
|
||||
|
||||
updateAccuracyStats(battle.stats);
|
||||
|
||||
numPassed = 0;
|
||||
|
||||
for (i = 0 ; i < MAX_CHALLENGES ; i++)
|
||||
for (i = 0; i < MAX_CHALLENGES; i++)
|
||||
{
|
||||
c = game.currentMission->challengeData.challenges[i];
|
||||
|
||||
|
@ -335,7 +336,7 @@ static void printStats(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < STAT_MAX ; i++)
|
||||
for (i = 0; i < STAT_MAX; i++)
|
||||
{
|
||||
if (battle.stats[i])
|
||||
{
|
||||
|
@ -492,10 +493,10 @@ char *getChallengeDescription(Challenge *c)
|
|||
|
||||
Challenge *getChallenge(Mission *mission, int type, int value)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Challenge *c;
|
||||
|
||||
for (i = 0 ; i < MAX_CHALLENGES ; i++)
|
||||
for (i = 0; i < MAX_CHALLENGES; i++)
|
||||
{
|
||||
c = mission->challengeData.challenges[i];
|
||||
|
||||
|
@ -523,15 +524,15 @@ static char *getFormattedChallengeDescription(const char *format, ...)
|
|||
|
||||
void updateChallengeMissions(void)
|
||||
{
|
||||
int i;
|
||||
Mission *m;
|
||||
int i;
|
||||
Mission *m;
|
||||
Challenge *c;
|
||||
|
||||
for (m = game.challengeMissionHead.next ; m != NULL ; m = m->next)
|
||||
for (m = game.challengeMissionHead.next; m != NULL; m = m->next)
|
||||
{
|
||||
m->totalChallenges = m->completedChallenges = 0;
|
||||
|
||||
for (i = 0 ; i < MAX_CHALLENGES ; i++)
|
||||
for (i = 0; i < MAX_CHALLENGES; i++)
|
||||
{
|
||||
c = m->challengeData.challenges[i];
|
||||
|
||||
|
@ -595,10 +596,10 @@ static void failChallenge(void)
|
|||
|
||||
static int alreadyPassed(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Challenge *c;
|
||||
|
||||
for (i = 0 ; i < MAX_CHALLENGES ; i++)
|
||||
for (i = 0; i < MAX_CHALLENGES; i++)
|
||||
{
|
||||
c = game.currentMission->challengeData.challenges[i];
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void updateChallengeMissions(void);
|
||||
void updateChallengeMissions(void);
|
||||
Challenge *getChallenge(Mission *mission, int type, int value);
|
||||
char *getChallengeDescription(Challenge *c);
|
||||
void doChallenges(void);
|
||||
void loadChallenge(Mission *mission, struct cJSON *node);
|
||||
void initChallenges(void);
|
||||
char *getChallengeDescription(Challenge *c);
|
||||
void doChallenges(void);
|
||||
void loadChallenge(Mission *mission, struct cJSON *node);
|
||||
void initChallenges(void);
|
||||
|
|
12
src/common.h
12
src/common.h
|
@ -18,15 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
#include "math.h"
|
||||
#include "ctype.h"
|
||||
|
||||
#include "SDL2/SDL.h"
|
||||
|
||||
#include "defs.h"
|
||||
#include "math.h"
|
||||
#include "SDL2/SDL.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "structs.h"
|
||||
|
||||
extern char *getTranslatedString(char *string);
|
||||
|
|
214
src/defs.h
214
src/defs.h
|
@ -19,156 +19,158 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#ifndef REVISION
|
||||
#define REVISION 0
|
||||
#define REVISION 0
|
||||
#endif
|
||||
|
||||
#ifndef DATA_DIR
|
||||
#define DATA_DIR ""
|
||||
#define DATA_DIR ""
|
||||
#endif
|
||||
|
||||
#ifndef FIXED_RESOLUTION
|
||||
#define FIXED_RESOLUTION 0
|
||||
#define FIXED_RESOLUTION 0
|
||||
#endif
|
||||
|
||||
#ifndef AUDIO_FREQUENCY
|
||||
#define AUDIO_FREQUENCY 44100
|
||||
#define AUDIO_FREQUENCY 44100
|
||||
#endif
|
||||
|
||||
#ifndef AUDIO_CHANNELS
|
||||
#define AUDIO_CHANNELS 2
|
||||
#define AUDIO_CHANNELS 2
|
||||
#endif
|
||||
|
||||
#ifndef AUDIO_CHUNKSIZE
|
||||
#define AUDIO_CHUNKSIZE 1024
|
||||
#define AUDIO_CHUNKSIZE 1024
|
||||
#endif
|
||||
|
||||
#ifndef AUDIO_MIX_CHANNELS
|
||||
#define AUDIO_MIX_CHANNELS 64
|
||||
#define AUDIO_MIX_CHANNELS 64
|
||||
#endif
|
||||
|
||||
#define _(string) getTranslatedString(string)
|
||||
|
||||
#define PI 3.14159265358979323846
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
#define CAROLINE(a,b) MIN(a,b)
|
||||
#define STRNCPY(dest, src, n) strncpy(dest, src, n); dest[n - 1] = '\0'
|
||||
#define PI 3.14159265358979323846
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define CAROLINE(a, b) MIN(a, b)
|
||||
#define STRNCPY(dest, src, n) \
|
||||
strncpy(dest, src, n); \
|
||||
dest[n - 1] = '\0'
|
||||
#define TO_RAIDANS(angleDegrees) (angleDegrees * PI / 180.0)
|
||||
#define TO_DEGREES(angleRadians) (angleRadians * 180.0 / PI)
|
||||
|
||||
#define SAVE_FILENAME "game.save"
|
||||
#define CONFIG_FILENAME "config.json"
|
||||
#define SAVE_FILENAME "game.save"
|
||||
#define CONFIG_FILENAME "config.json"
|
||||
|
||||
#define SCREEN_WIDTH 1280
|
||||
#define SCREEN_HEIGHT 720
|
||||
#define SCREEN_WIDTH 1280
|
||||
#define SCREEN_HEIGHT 720
|
||||
|
||||
#define UI_WIDTH 1280
|
||||
#define UI_HEIGHT 720
|
||||
#define UI_WIDTH 1280
|
||||
#define UI_HEIGHT 720
|
||||
|
||||
#define MAX_KEYBOARD_KEYS 350
|
||||
#define MAX_MOUSE_BUTTONS 6
|
||||
#define MAX_KEYBOARD_KEYS 350
|
||||
#define MAX_MOUSE_BUTTONS 6
|
||||
|
||||
#define FPS 60
|
||||
#define FPS 60
|
||||
|
||||
#define MAX_NAME_LENGTH 32
|
||||
#define MAX_DESCRIPTION_LENGTH 512
|
||||
#define MAX_LINE_LENGTH 1024
|
||||
#define MAX_FILENAME_LENGTH 1024
|
||||
#define MAX_PATH_LENGTH 4096
|
||||
#define MAX_NAME_LENGTH 32
|
||||
#define MAX_DESCRIPTION_LENGTH 512
|
||||
#define MAX_LINE_LENGTH 1024
|
||||
#define MAX_FILENAME_LENGTH 1024
|
||||
#define MAX_PATH_LENGTH 4096
|
||||
|
||||
#define NUM_TEXTURE_BUCKETS 32
|
||||
#define NUM_ATLAS_BUCKETS 64
|
||||
#define NUM_TEXTURE_BUCKETS 32
|
||||
#define NUM_ATLAS_BUCKETS 64
|
||||
|
||||
#define MAX_GLYPHS 400
|
||||
#define MAX_GLYPHS 400
|
||||
|
||||
#define MAX_STARS 500
|
||||
#define MAX_STARS 500
|
||||
|
||||
#define MAX_CHALLENGES 3
|
||||
#define MAX_CHALLENGES 3
|
||||
|
||||
#define MAX_FIGHTER_GUNS 12
|
||||
#define MAX_TARGET_RANGE 65536
|
||||
#define MAX_SYSTEM_POWER 100
|
||||
#define MAX_FIGHTER_GUNS 12
|
||||
#define MAX_TARGET_RANGE 65536
|
||||
#define MAX_SYSTEM_POWER 100
|
||||
|
||||
#define BATTLE_AREA_CELLS 50
|
||||
#define BATTLE_AREA_WIDTH (640 * BATTLE_AREA_CELLS)
|
||||
#define BATTLE_AREA_HEIGHT (360 * BATTLE_AREA_CELLS)
|
||||
#define BATTLE_AREA_EDGE 250
|
||||
#define BATTLE_AREA_CELLS 50
|
||||
#define BATTLE_AREA_WIDTH (640 * BATTLE_AREA_CELLS)
|
||||
#define BATTLE_AREA_HEIGHT (360 * BATTLE_AREA_CELLS)
|
||||
#define BATTLE_AREA_EDGE 250
|
||||
|
||||
#define BF_NONE 0
|
||||
#define BF_ENGINE (2 << 0)
|
||||
#define BF_SYSTEM_DAMAGE (2 << 1)
|
||||
#define BF_SHIELD_DAMAGE (2 << 2)
|
||||
#define BF_EXPLODES (2 << 3)
|
||||
#define BF_NONE 0
|
||||
#define BF_ENGINE (2 << 0)
|
||||
#define BF_SYSTEM_DAMAGE (2 << 1)
|
||||
#define BF_SHIELD_DAMAGE (2 << 2)
|
||||
#define BF_EXPLODES (2 << 3)
|
||||
|
||||
#define EF_NONE 0
|
||||
#define EF_NO_KILL (2 << 0)
|
||||
#define EF_DISABLED (2 << 1)
|
||||
#define EF_IMMORTAL (2 << 2)
|
||||
#define EF_MISSION_TARGET (2 << 3)
|
||||
#define EF_NO_MT_BOX (2 << 4)
|
||||
#define EF_HAS_ROPE (2 << 5)
|
||||
#define EF_COLLECTS_ITEMS (2 << 6)
|
||||
#define EF_MUST_DISABLE (2 << 7)
|
||||
#define EF_RETREATING (2 << 8)
|
||||
#define EF_NO_EPIC (2 << 9)
|
||||
#define EF_STATIC (2 << 10)
|
||||
#define EF_TAKES_DAMAGE (2 << 11)
|
||||
#define EF_SECONDARY_TARGET (2 << 12)
|
||||
#define EF_AI_TARGET (2 << 13)
|
||||
#define EF_AI_LEADER (2 << 14)
|
||||
#define EF_ROPED_ATTACHED (2 << 15)
|
||||
#define EF_NO_KILL_INC (2 << 16)
|
||||
#define EF_SHORT_RADAR_RANGE (2 << 17)
|
||||
#define EF_NO_PLAYER_TARGET (2 << 18)
|
||||
#define EF_AI_IGNORE (2 << 19)
|
||||
#define EF_NON_SOLID (2 << 20)
|
||||
#define EF_NO_HEALTH_BAR (2 << 21)
|
||||
#define EF_FRIENDLY_HEALTH_BAR (2 << 22)
|
||||
#define EF_NO_THREAT (2 << 23)
|
||||
#define EF_DROPS_ITEMS (2 << 24)
|
||||
#define EF_COMMON_FIGHTER (2 << 25)
|
||||
#define EF_NONE 0
|
||||
#define EF_NO_KILL (2 << 0)
|
||||
#define EF_DISABLED (2 << 1)
|
||||
#define EF_IMMORTAL (2 << 2)
|
||||
#define EF_MISSION_TARGET (2 << 3)
|
||||
#define EF_NO_MT_BOX (2 << 4)
|
||||
#define EF_HAS_ROPE (2 << 5)
|
||||
#define EF_COLLECTS_ITEMS (2 << 6)
|
||||
#define EF_MUST_DISABLE (2 << 7)
|
||||
#define EF_RETREATING (2 << 8)
|
||||
#define EF_NO_EPIC (2 << 9)
|
||||
#define EF_STATIC (2 << 10)
|
||||
#define EF_TAKES_DAMAGE (2 << 11)
|
||||
#define EF_SECONDARY_TARGET (2 << 12)
|
||||
#define EF_AI_TARGET (2 << 13)
|
||||
#define EF_AI_LEADER (2 << 14)
|
||||
#define EF_ROPED_ATTACHED (2 << 15)
|
||||
#define EF_NO_KILL_INC (2 << 16)
|
||||
#define EF_SHORT_RADAR_RANGE (2 << 17)
|
||||
#define EF_NO_PLAYER_TARGET (2 << 18)
|
||||
#define EF_AI_IGNORE (2 << 19)
|
||||
#define EF_NON_SOLID (2 << 20)
|
||||
#define EF_NO_HEALTH_BAR (2 << 21)
|
||||
#define EF_FRIENDLY_HEALTH_BAR (2 << 22)
|
||||
#define EF_NO_THREAT (2 << 23)
|
||||
#define EF_DROPS_ITEMS (2 << 24)
|
||||
#define EF_COMMON_FIGHTER (2 << 25)
|
||||
|
||||
#define AIF_NONE 0
|
||||
#define AIF_FOLLOWS_PLAYER (2 << 0)
|
||||
#define AIF_MOVES_TO_PLAYER (2 << 1)
|
||||
#define AIF_UNLIMITED_RANGE (2 << 2)
|
||||
#define AIF_COLLECTS_ITEMS (2 << 3)
|
||||
#define AIF_TOWS (2 << 4)
|
||||
#define AIF_RETREATS (2 << 5)
|
||||
#define AIF_GOAL_JUMPGATE (2 << 6)
|
||||
#define AIF_AVOIDS_COMBAT (2 << 7)
|
||||
#define AIF_DEFENSIVE (2 << 8)
|
||||
#define AIF_MISSILE_BOAT (2 << 9)
|
||||
#define AIF_AGGRESSIVE (2 << 10)
|
||||
#define AIF_LONG_RANGE_FIRE (2 << 11)
|
||||
#define AIF_MOVES_TO_LEADER (2 << 12)
|
||||
#define AIF_EVADE (2 << 13)
|
||||
#define AIF_WANDERS (2 << 14)
|
||||
#define AIF_COVERS_RETREAT (2 << 15)
|
||||
#define AIF_TARGET_FOCUS (2 << 16)
|
||||
#define AIF_DROPS_MINES (2 << 17)
|
||||
#define AIF_ASSASSIN (2 << 18)
|
||||
#define AIF_SUSPICIOUS (2 << 19)
|
||||
#define AIF_ZAK_SUSPICIOUS (2 << 20)
|
||||
#define AIF_SURRENDERS (2 << 21)
|
||||
#define AIF_SURRENDERING (2 << 22)
|
||||
#define AIF_SURRENDERED (2 << 23)
|
||||
#define AIF_NONE 0
|
||||
#define AIF_FOLLOWS_PLAYER (2 << 0)
|
||||
#define AIF_MOVES_TO_PLAYER (2 << 1)
|
||||
#define AIF_UNLIMITED_RANGE (2 << 2)
|
||||
#define AIF_COLLECTS_ITEMS (2 << 3)
|
||||
#define AIF_TOWS (2 << 4)
|
||||
#define AIF_RETREATS (2 << 5)
|
||||
#define AIF_GOAL_JUMPGATE (2 << 6)
|
||||
#define AIF_AVOIDS_COMBAT (2 << 7)
|
||||
#define AIF_DEFENSIVE (2 << 8)
|
||||
#define AIF_MISSILE_BOAT (2 << 9)
|
||||
#define AIF_AGGRESSIVE (2 << 10)
|
||||
#define AIF_LONG_RANGE_FIRE (2 << 11)
|
||||
#define AIF_MOVES_TO_LEADER (2 << 12)
|
||||
#define AIF_EVADE (2 << 13)
|
||||
#define AIF_WANDERS (2 << 14)
|
||||
#define AIF_COVERS_RETREAT (2 << 15)
|
||||
#define AIF_TARGET_FOCUS (2 << 16)
|
||||
#define AIF_DROPS_MINES (2 << 17)
|
||||
#define AIF_ASSASSIN (2 << 18)
|
||||
#define AIF_SUSPICIOUS (2 << 19)
|
||||
#define AIF_ZAK_SUSPICIOUS (2 << 20)
|
||||
#define AIF_SURRENDERS (2 << 21)
|
||||
#define AIF_SURRENDERING (2 << 22)
|
||||
#define AIF_SURRENDERED (2 << 23)
|
||||
|
||||
/* player abilities */
|
||||
#define BOOST_RECHARGE_TIME (FPS * 7)
|
||||
#define BOOST_FINISHED_TIME (FPS * 0.75)
|
||||
#define ECM_RECHARGE_TIME (FPS * 7)
|
||||
#define BOOST_RECHARGE_TIME (FPS * 7)
|
||||
#define BOOST_FINISHED_TIME (FPS * 0.75)
|
||||
#define ECM_RECHARGE_TIME (FPS * 7)
|
||||
|
||||
#define MB_NORMAL 0
|
||||
#define MB_IMPORTANT 1
|
||||
#define MB_PANDORAN 2
|
||||
#define MB_NORMAL 0
|
||||
#define MB_IMPORTANT 1
|
||||
#define MB_PANDORAN 2
|
||||
|
||||
#define SS_NORMAL 0
|
||||
#define SS_SOL 1
|
||||
#define SS_PANDORAN 2
|
||||
#define SS_NORMAL 0
|
||||
#define SS_SOL 1
|
||||
#define SS_PANDORAN 2
|
||||
|
||||
#define MAX_SUSPICION_LEVEL 1500.0
|
||||
#define MAX_ZAK_SUSPICION_LEVEL (FPS * 30)
|
||||
#define MAX_SUSPICION_LEVEL 1500.0
|
||||
#define MAX_ZAK_SUSPICION_LEVEL (FPS * 30)
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -19,94 +19,95 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "galacticMap.h"
|
||||
#include "../battle/starfield.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/input.h"
|
||||
#include "../game/title.h"
|
||||
#include "../game/stats.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../system/modalDialog.h"
|
||||
#include "../game/options.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../game/fighterDatabase.h"
|
||||
#include "../system/transition.h"
|
||||
#include "../system/text.h"
|
||||
#include "../galaxy/starSystems.h"
|
||||
#include "../system/draw.h"
|
||||
|
||||
#include "../battle/battle.h"
|
||||
#include "../battle/starfield.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../galaxy/starSystems.h"
|
||||
#include "../game/fighterDatabase.h"
|
||||
#include "../game/options.h"
|
||||
#include "../game/stats.h"
|
||||
#include "../game/title.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/input.h"
|
||||
#include "../system/modalDialog.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/textures.h"
|
||||
#include "../system/transition.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "galacticMap.h"
|
||||
|
||||
#define MAX_LISTED_MISSIONS 9
|
||||
#define SHOW_FIGHTER_DB 6
|
||||
#define SHOW_GALAXY 0
|
||||
#define SHOW_MENU 2
|
||||
#define SHOW_OPTIONS 3
|
||||
#define SHOW_STAR_SYSTEM 1
|
||||
#define SHOW_STATS 4
|
||||
#define SHOW_TROPHIES 5
|
||||
#define MAX_LISTED_MISSIONS 9
|
||||
#define SHOW_FIGHTER_DB 6
|
||||
#define SHOW_GALAXY 0
|
||||
#define SHOW_MENU 2
|
||||
#define SHOW_OPTIONS 3
|
||||
#define SHOW_STAR_SYSTEM 1
|
||||
#define SHOW_STATS 4
|
||||
#define SHOW_TROPHIES 5
|
||||
|
||||
extern App app;
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
extern Game game;
|
||||
extern Game game;
|
||||
|
||||
static void logic(void);
|
||||
static void draw(void);
|
||||
static void handleKeyboard(void);
|
||||
static void handleMouse(void);
|
||||
static void scrollGalaxy(void);
|
||||
static void drawStarSystemDetail(void);
|
||||
static void selectStarSystem(void);
|
||||
static void drawGalaxy(void);
|
||||
static void centerOnSelectedStarSystem(void);
|
||||
static void doStarSystems(void);
|
||||
static void drawPulses(void);
|
||||
static void drawInfoBars(void);
|
||||
static void doPulses(void);
|
||||
static void addPulses(void);
|
||||
static void drawMenu(void);
|
||||
static void resume(void);
|
||||
static void stats(void);
|
||||
static void trophies(void);
|
||||
static void options(void);
|
||||
static void ok(void);
|
||||
static void quit(void);
|
||||
static void startMission(void);
|
||||
static void returnFromOptions(void);
|
||||
static void doStarSystemView(void);
|
||||
static void updatePandoranAdvance(void);
|
||||
static void fallenOK(void);
|
||||
static void updateCampaignProgress(void);
|
||||
static void campaignCompleteOK(void);
|
||||
static void logic(void);
|
||||
static void draw(void);
|
||||
static void handleKeyboard(void);
|
||||
static void handleMouse(void);
|
||||
static void scrollGalaxy(void);
|
||||
static void drawStarSystemDetail(void);
|
||||
static void selectStarSystem(void);
|
||||
static void drawGalaxy(void);
|
||||
static void centerOnSelectedStarSystem(void);
|
||||
static void doStarSystems(void);
|
||||
static void drawPulses(void);
|
||||
static void drawInfoBars(void);
|
||||
static void doPulses(void);
|
||||
static void addPulses(void);
|
||||
static void drawMenu(void);
|
||||
static void resume(void);
|
||||
static void stats(void);
|
||||
static void trophies(void);
|
||||
static void options(void);
|
||||
static void ok(void);
|
||||
static void quit(void);
|
||||
static void startMission(void);
|
||||
static void returnFromOptions(void);
|
||||
static void doStarSystemView(void);
|
||||
static void updatePandoranAdvance(void);
|
||||
static void fallenOK(void);
|
||||
static void updateCampaignProgress(void);
|
||||
static void campaignCompleteOK(void);
|
||||
static Mission *nextAvailableMission(StarSystem *starSystem);
|
||||
static void fighterDatabase(void);
|
||||
static void fighterDatabase(void);
|
||||
|
||||
static StarSystem *selectedStarSystem;
|
||||
static StarSystem *selectedStarSystem;
|
||||
static SDL_Texture *background;
|
||||
static AtlasImage *starSystemTexture;
|
||||
static AtlasImage *arrowTexture;
|
||||
static SDL_Point camera;
|
||||
static Pulse pulseHead = {0};
|
||||
static Pulse *pulseTail;
|
||||
static int pulseTimer;
|
||||
static float ssx, ssy;
|
||||
static float arrowPulse;
|
||||
static int show;
|
||||
static int scrollingMap;
|
||||
static int campaignComplete = 0;
|
||||
static PointF cameraMin, cameraMax;
|
||||
static Widget *startMissionButton;
|
||||
static Mission *hoverMission;
|
||||
static char *MISSIONS_TEXT;
|
||||
static char *PILOT_TEXT;
|
||||
static char *CRAFT_TEXT;
|
||||
static char *SQUADRON_TEXT;
|
||||
static char *COMPLETED_TEXT;
|
||||
static char *EPIC_TEXT;
|
||||
static char *OPTIONAL_TEXT;
|
||||
static AtlasImage *starSystemTexture;
|
||||
static AtlasImage *arrowTexture;
|
||||
static SDL_Point camera;
|
||||
static Pulse pulseHead = {0};
|
||||
static Pulse *pulseTail;
|
||||
static int pulseTimer;
|
||||
static float ssx, ssy;
|
||||
static float arrowPulse;
|
||||
static int show;
|
||||
static int scrollingMap;
|
||||
static int campaignComplete = 0;
|
||||
static PointF cameraMin, cameraMax;
|
||||
static Widget *startMissionButton;
|
||||
static Mission *hoverMission;
|
||||
static char *MISSIONS_TEXT;
|
||||
static char *PILOT_TEXT;
|
||||
static char *CRAFT_TEXT;
|
||||
static char *SQUADRON_TEXT;
|
||||
static char *COMPLETED_TEXT;
|
||||
static char *EPIC_TEXT;
|
||||
static char *OPTIONAL_TEXT;
|
||||
|
||||
void initGalacticMap(void)
|
||||
{
|
||||
|
@ -193,7 +194,7 @@ static void updateCampaignProgress(void)
|
|||
|
||||
if (!campaignComplete && game.completedMissions == game.totalMissions)
|
||||
{
|
||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||
for (starSystem = game.starSystemHead.next; starSystem != NULL; starSystem = starSystem->next)
|
||||
{
|
||||
if (starSystem->missionHead.next && starSystem->missionHead.next->available)
|
||||
{
|
||||
|
@ -213,7 +214,7 @@ static void updatePandoranAdvance(void)
|
|||
|
||||
fallenStarSystem = NULL;
|
||||
|
||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||
for (starSystem = game.starSystemHead.next; starSystem != NULL; starSystem = starSystem->next)
|
||||
{
|
||||
if (starSystem->side != SIDE_PANDORAN && starSystem->fallsToPandorans && starSystem->completedMissions == starSystem->totalMissions && starSystem->totalMissions > 0)
|
||||
{
|
||||
|
@ -274,7 +275,7 @@ static void logic(void)
|
|||
static void doStarSystems(void)
|
||||
{
|
||||
StarSystem *starSystem;
|
||||
int cx, cy;
|
||||
int cx, cy;
|
||||
|
||||
if (!scrollingMap)
|
||||
{
|
||||
|
@ -286,7 +287,7 @@ static void doStarSystems(void)
|
|||
|
||||
selectedStarSystem = NULL;
|
||||
|
||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||
for (starSystem = game.starSystemHead.next; starSystem != NULL; starSystem = starSystem->next)
|
||||
{
|
||||
cameraMin.x = MIN(cameraMin.x, starSystem->x);
|
||||
cameraMin.y = MIN(cameraMin.y, starSystem->y);
|
||||
|
@ -357,7 +358,7 @@ static void doStarSystemView(void)
|
|||
{
|
||||
Mission *mission;
|
||||
|
||||
for (mission = selectedStarSystem->missionHead.next ; mission != NULL ; mission = mission->next)
|
||||
for (mission = selectedStarSystem->missionHead.next; mission != NULL; mission = mission->next)
|
||||
{
|
||||
if (mission->available && collision(app.uiMouse.x - app.mouse.w / 2, app.uiMouse.y - app.mouse.h / 2, app.mouse.w, app.mouse.h, mission->rect.x, mission->rect.y, mission->rect.w, mission->rect.h))
|
||||
{
|
||||
|
@ -387,10 +388,10 @@ static void doStarSystemView(void)
|
|||
|
||||
static void addPulses(void)
|
||||
{
|
||||
Pulse *pulse;
|
||||
Pulse *pulse;
|
||||
StarSystem *starSystem;
|
||||
|
||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||
for (starSystem = game.starSystemHead.next; starSystem != NULL; starSystem = starSystem->next)
|
||||
{
|
||||
if (starSystem->completedMissions < starSystem->availableMissions || (campaignComplete && starSystem->activeMission))
|
||||
{
|
||||
|
@ -439,7 +440,7 @@ static void doPulses(void)
|
|||
|
||||
prev = &pulseHead;
|
||||
|
||||
for (pulse = pulseHead.next ; pulse != NULL ; pulse = pulse->next)
|
||||
for (pulse = pulseHead.next; pulse != NULL; pulse = pulse->next)
|
||||
{
|
||||
pulse->size += 0.5;
|
||||
pulse->life--;
|
||||
|
@ -504,7 +505,7 @@ static void drawPulses(void)
|
|||
{
|
||||
Pulse *pulse;
|
||||
|
||||
for (pulse = pulseHead.next ; pulse != NULL ; pulse = pulse->next)
|
||||
for (pulse = pulseHead.next; pulse != NULL; pulse = pulse->next)
|
||||
{
|
||||
drawCircle(pulse->x - camera.x, pulse->y - camera.y, pulse->size, pulse->r, pulse->g, pulse->b, pulse->life);
|
||||
}
|
||||
|
@ -521,12 +522,12 @@ static void centerOnSelectedStarSystem(void)
|
|||
|
||||
static void drawGalaxy(void)
|
||||
{
|
||||
SDL_Rect r;
|
||||
SDL_Rect r;
|
||||
StarSystem *starSystem;
|
||||
SDL_Color color;
|
||||
float ax, ay, aa;
|
||||
SDL_Color color;
|
||||
float ax, ay, aa;
|
||||
|
||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||
for (starSystem = game.starSystemHead.next; starSystem != NULL; starSystem = starSystem->next)
|
||||
{
|
||||
r.x = starSystem->x - camera.x;
|
||||
r.y = starSystem->y - camera.y;
|
||||
|
@ -651,7 +652,7 @@ static Mission *nextAvailableMission(StarSystem *starSystem)
|
|||
{
|
||||
Mission *m;
|
||||
|
||||
for (m = starSystem->missionHead.next ; m != NULL ; m = m->next)
|
||||
for (m = starSystem->missionHead.next; m != NULL; m = m->next)
|
||||
{
|
||||
if (m->available && !m->completed)
|
||||
{
|
||||
|
@ -664,7 +665,7 @@ static Mission *nextAvailableMission(StarSystem *starSystem)
|
|||
|
||||
static void drawStarSystemDetail(void)
|
||||
{
|
||||
int y;
|
||||
int y;
|
||||
Mission *mission;
|
||||
SDL_Rect r;
|
||||
|
||||
|
@ -694,7 +695,7 @@ static void drawStarSystemDetail(void)
|
|||
|
||||
y += 80;
|
||||
|
||||
for (mission = selectedStarSystem->missionHead.next ; mission != NULL ; mission = mission->next)
|
||||
for (mission = selectedStarSystem->missionHead.next; mission != NULL; mission = mission->next)
|
||||
{
|
||||
mission->rect.x = 200;
|
||||
mission->rect.y = y - 2;
|
||||
|
|
|
@ -18,44 +18,46 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "mission.h"
|
||||
#include <time.h>
|
||||
#include "../json/cJSON.h"
|
||||
#include "../battle/locations.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../system/io.h"
|
||||
#include "../galaxy/starSystems.h"
|
||||
#include "../battle/jumpgate.h"
|
||||
#include "../battle/missionInfo.h"
|
||||
#include "../system/util.h"
|
||||
#include "../battle/player.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/transition.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../battle/waypoints.h"
|
||||
#include "../battle/spawners.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../battle/mine.h"
|
||||
#include "../challenges/challenges.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/resources.h"
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#include "../battle/capitalShips.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../system/textures.h"
|
||||
#include "../battle/items.h"
|
||||
#include "../battle/entities.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../battle/items.h"
|
||||
#include "../battle/jumpgate.h"
|
||||
#include "../battle/locations.h"
|
||||
#include "../battle/mine.h"
|
||||
#include "../battle/missionInfo.h"
|
||||
#include "../battle/objectives.h"
|
||||
#include "../battle/player.h"
|
||||
#include "../battle/script.h"
|
||||
#include "../battle/spawners.h"
|
||||
#include "../battle/waypoints.h"
|
||||
#include "../challenges/challenges.h"
|
||||
#include "../galaxy/starSystems.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/resources.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/textures.h"
|
||||
#include "../system/transition.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "mission.h"
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Dev dev;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Dev dev;
|
||||
extern Entity *player;
|
||||
extern Game game;
|
||||
extern Game game;
|
||||
|
||||
static void loadEntities(cJSON *node);
|
||||
static void loadEpicData(cJSON *node);
|
||||
static void loadEntities(cJSON *node);
|
||||
static void loadEpicData(cJSON *node);
|
||||
static char *getAutoBackground(char *filename);
|
||||
static char *getAutoPlanet(char *filename);
|
||||
static char *getAutoMusic(char *filename);
|
||||
|
@ -63,8 +65,8 @@ static char *getAutoMusic(char *filename);
|
|||
Mission *loadMissionMeta(char *filename)
|
||||
{
|
||||
Mission *mission;
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Loading %s", filename);
|
||||
|
||||
|
@ -126,8 +128,8 @@ Mission *loadMissionMeta(char *filename)
|
|||
void loadMission(char *filename)
|
||||
{
|
||||
cJSON *root;
|
||||
char *text, music[MAX_DESCRIPTION_LENGTH], *background, *planet;
|
||||
float planetScale;
|
||||
char *text, music[MAX_DESCRIPTION_LENGTH], *background, *planet;
|
||||
float planetScale;
|
||||
|
||||
startSectionTransition();
|
||||
|
||||
|
@ -346,10 +348,10 @@ void failMission(void)
|
|||
static void loadEntities(cJSON *node)
|
||||
{
|
||||
Entity *e;
|
||||
char *name, *groupName;
|
||||
int i, type, scatter, number, active, addFlags, side;
|
||||
float x, y;
|
||||
long flags;
|
||||
char *name, *groupName;
|
||||
int i, type, scatter, number, active, addFlags, side;
|
||||
float x, y;
|
||||
long flags;
|
||||
|
||||
if (node)
|
||||
{
|
||||
|
@ -377,7 +379,7 @@ static void loadEntities(cJSON *node)
|
|||
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring, &addFlags);
|
||||
}
|
||||
|
||||
for (i = 0 ; i < number ; i++)
|
||||
for (i = 0; i < number; i++)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -447,7 +449,7 @@ static void loadEntities(cJSON *node)
|
|||
static void loadEpicData(cJSON *node)
|
||||
{
|
||||
Entity *e;
|
||||
int numFighters[SIDE_MAX];
|
||||
int numFighters[SIDE_MAX];
|
||||
memset(numFighters, 0, sizeof(int) * SIDE_MAX);
|
||||
|
||||
battle.isEpic = 1;
|
||||
|
@ -467,7 +469,7 @@ static void loadEpicData(cJSON *node)
|
|||
addEpicKillsObjective();
|
||||
}
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
for (e = battle.entityHead.next; e != NULL; e = e->next)
|
||||
{
|
||||
if (e->active && e->type == ET_FIGHTER && numFighters[e->side]++ >= battle.epicFighterLimit)
|
||||
{
|
||||
|
@ -479,12 +481,12 @@ static void loadEpicData(cJSON *node)
|
|||
Mission *getMission(char *filename)
|
||||
{
|
||||
StarSystem *starSystem;
|
||||
Mission *mission;
|
||||
Mission *mission;
|
||||
|
||||
/* First, search the star systems */
|
||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||
for (starSystem = game.starSystemHead.next; starSystem != NULL; starSystem = starSystem->next)
|
||||
{
|
||||
for (mission = starSystem->missionHead.next ; mission != NULL ; mission = mission->next)
|
||||
for (mission = starSystem->missionHead.next; mission != NULL; mission = mission->next)
|
||||
{
|
||||
if (strcmp(mission->filename, filename) == 0)
|
||||
{
|
||||
|
@ -494,7 +496,7 @@ Mission *getMission(char *filename)
|
|||
}
|
||||
|
||||
/* now search the challenges */
|
||||
for (mission = game.challengeMissionHead.next ; mission != NULL ; mission = mission->next)
|
||||
for (mission = game.challengeMissionHead.next; mission != NULL; mission = mission->next)
|
||||
{
|
||||
if (strcmp(mission->filename, filename) == 0)
|
||||
{
|
||||
|
@ -522,10 +524,6 @@ int isMissionAvailable(Mission *mission, Mission *prev)
|
|||
}
|
||||
else
|
||||
{
|
||||
return mission->completed || (
|
||||
game.completedMissions >= mission->requires &&
|
||||
game.stats[STAT_OPTIONAL_COMPLETED] >= mission->requiresOptional &&
|
||||
game.completedMissions < mission->expires
|
||||
) || dev.debug;
|
||||
return mission->completed || (game.completedMissions >= mission->requires && game.stats[STAT_OPTIONAL_COMPLETED] >= mission->requiresOptional && game.completedMissions < mission->expires) || dev.debug;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
int isMissionAvailable(Mission *mission, Mission *prev);
|
||||
void updateAllMissions(void);
|
||||
int isMissionAvailable(Mission *mission, Mission *prev);
|
||||
void updateAllMissions(void);
|
||||
Mission *getMission(char *filename);
|
||||
void failMission(void);
|
||||
void completeMission(void);
|
||||
void loadMission(char *filename);
|
||||
void failMission(void);
|
||||
void completeMission(void);
|
||||
void loadMission(char *filename);
|
||||
Mission *loadMissionMeta(char *filename);
|
||||
|
|
|
@ -19,22 +19,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "starSystems.h"
|
||||
#include "../json/cJSON.h"
|
||||
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/io.h"
|
||||
#include "starSystems.h"
|
||||
|
||||
extern Game game;
|
||||
|
||||
static void loadMissions(StarSystem *starSystem);
|
||||
static void loadMissions(StarSystem *starSystem);
|
||||
static StarSystem *loadStarSystem(cJSON *starSystemJSON);
|
||||
|
||||
void initStarSystems(void)
|
||||
{
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
StarSystem *starSystem, *tail;
|
||||
|
||||
tail = &game.starSystemHead;
|
||||
|
@ -42,7 +43,7 @@ void initStarSystems(void)
|
|||
text = readFile("data/galaxy/starSystems.json");
|
||||
root = cJSON_Parse(text);
|
||||
|
||||
for (node = cJSON_GetObjectItem(root, "starSystems")->child ; node != NULL ; node = node->next)
|
||||
for (node = cJSON_GetObjectItem(root, "starSystems")->child; node != NULL; node = node->next)
|
||||
{
|
||||
starSystem = loadStarSystem(node);
|
||||
tail->next = starSystem;
|
||||
|
@ -85,17 +86,17 @@ static StarSystem *loadStarSystem(cJSON *starSystemJSON)
|
|||
|
||||
static void loadMissions(StarSystem *starSystem)
|
||||
{
|
||||
int i, count;
|
||||
char name[MAX_NAME_LENGTH];
|
||||
char path[MAX_FILENAME_LENGTH];
|
||||
char **filenames;
|
||||
int i, count;
|
||||
char name[MAX_NAME_LENGTH];
|
||||
char path[MAX_FILENAME_LENGTH];
|
||||
char **filenames;
|
||||
Mission *mission, *tail;
|
||||
|
||||
tail = &starSystem->missionHead;
|
||||
|
||||
STRNCPY(name, starSystem->name, MAX_NAME_LENGTH);
|
||||
|
||||
for (i = 0 ; name[i] ; i++)
|
||||
for (i = 0; name[i]; i++)
|
||||
{
|
||||
name[i] = tolower(name[i]);
|
||||
}
|
||||
|
@ -104,7 +105,7 @@ static void loadMissions(StarSystem *starSystem)
|
|||
|
||||
filenames = getFileList(path, &count);
|
||||
|
||||
for (i = 0 ; i < count ; i++)
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
sprintf(path, "data/missions/%s/%s", name, filenames[i]);
|
||||
|
||||
|
@ -126,7 +127,7 @@ StarSystem *getStarSystem(char *name)
|
|||
{
|
||||
StarSystem *starSystem;
|
||||
|
||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||
for (starSystem = game.starSystemHead.next; starSystem != NULL; starSystem = starSystem->next)
|
||||
{
|
||||
if (strcmp(starSystem->name, name) == 0)
|
||||
{
|
||||
|
@ -140,15 +141,15 @@ StarSystem *getStarSystem(char *name)
|
|||
void updateStarSystemMissions(void)
|
||||
{
|
||||
StarSystem *starSystem;
|
||||
Mission *mission, *prev;
|
||||
Mission *mission, *prev;
|
||||
|
||||
game.completedMissions = game.totalMissions = game.availableMissions = 0;
|
||||
|
||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||
for (starSystem = game.starSystemHead.next; starSystem != NULL; starSystem = starSystem->next)
|
||||
{
|
||||
starSystem->completedMissions = starSystem->availableMissions = starSystem->totalMissions = 0;
|
||||
|
||||
for (mission = starSystem->missionHead.next ; mission != NULL ; mission = mission->next)
|
||||
for (mission = starSystem->missionHead.next; mission != NULL; mission = mission->next)
|
||||
{
|
||||
starSystem->totalMissions++;
|
||||
|
||||
|
@ -169,11 +170,11 @@ void updateStarSystemMissions(void)
|
|||
}
|
||||
}
|
||||
|
||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||
for (starSystem = game.starSystemHead.next; starSystem != NULL; starSystem = starSystem->next)
|
||||
{
|
||||
prev = &starSystem->missionHead;
|
||||
|
||||
for (mission = starSystem->missionHead.next ; mission != NULL ; mission = mission->next)
|
||||
for (mission = starSystem->missionHead.next; mission != NULL; mission = mission->next)
|
||||
{
|
||||
mission->available = starSystem->type == SS_SOL || isMissionAvailable(mission, prev);
|
||||
|
||||
|
@ -202,7 +203,7 @@ void updateStarSystemMissions(void)
|
|||
void destroyStarSystems(void)
|
||||
{
|
||||
StarSystem *starSystem;
|
||||
Mission *mission;
|
||||
Mission *mission;
|
||||
|
||||
while (game.starSystemHead.next)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void destroyStarSystems(void);
|
||||
void updateStarSystemMissions(void);
|
||||
void destroyStarSystems(void);
|
||||
void updateStarSystemMissions(void);
|
||||
StarSystem *getStarSystem(char *name);
|
||||
void initStarSystems(void);
|
||||
void initStarSystems(void);
|
||||
|
|
|
@ -19,20 +19,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "credits.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/draw.h"
|
||||
|
||||
#include "../game/title.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/transition.h"
|
||||
#include "../system/textures.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/text.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/textures.h"
|
||||
#include "../system/transition.h"
|
||||
#include "credits.h"
|
||||
|
||||
#define CREDIT_LINE_LIMIT (UI_WIDTH - 300)
|
||||
#define CREDIT_LINE_LIMIT (UI_WIDTH - 300)
|
||||
|
||||
extern App app;
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
|
||||
static void loadCredits(void);
|
||||
|
@ -41,11 +42,11 @@ static void draw(void);
|
|||
static void handleKeyboard(void);
|
||||
|
||||
static SDL_Texture *background;
|
||||
static AtlasImage *earthTexture;
|
||||
static Credit head;
|
||||
static Credit *tail;
|
||||
static float creditSpeed;
|
||||
static int timeout;
|
||||
static AtlasImage *earthTexture;
|
||||
static Credit head;
|
||||
static Credit *tail;
|
||||
static float creditSpeed;
|
||||
static int timeout;
|
||||
|
||||
void initCredits(void)
|
||||
{
|
||||
|
@ -79,7 +80,7 @@ static void logic(void)
|
|||
|
||||
handleKeyboard();
|
||||
|
||||
for (c = head.next ; c != NULL ; c = c->next)
|
||||
for (c = head.next; c != NULL; c = c->next)
|
||||
{
|
||||
c->y -= creditSpeed;
|
||||
|
||||
|
@ -109,7 +110,7 @@ static void draw(void)
|
|||
|
||||
app.textWidth = CREDIT_LINE_LIMIT;
|
||||
|
||||
for (c = head.next ; c != NULL ; c = c->next)
|
||||
for (c = head.next; c != NULL; c = c->next)
|
||||
{
|
||||
if (c->y > -c->h && c->y < app.winHeight)
|
||||
{
|
||||
|
@ -122,9 +123,9 @@ static void draw(void)
|
|||
|
||||
static void loadCredits(void)
|
||||
{
|
||||
cJSON *root, *node;
|
||||
int y, dist;
|
||||
char *text;
|
||||
cJSON *root, *node;
|
||||
int y, dist;
|
||||
char *text;
|
||||
Credit *c;
|
||||
|
||||
y = app.winHeight + 100;
|
||||
|
@ -134,7 +135,7 @@ static void loadCredits(void)
|
|||
|
||||
app.textWidth = CREDIT_LINE_LIMIT;
|
||||
|
||||
for (node = root->child ; node != NULL ; node = node->next)
|
||||
for (node = root->child; node != NULL; node = node->next)
|
||||
{
|
||||
c = malloc(sizeof(Credit));
|
||||
memset(c, 0, sizeof(Credit));
|
||||
|
|
|
@ -19,40 +19,41 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "fighterDatabase.h"
|
||||
#include "../system/text.h"
|
||||
|
||||
#include "../battle/fighters.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "fighterDatabase.h"
|
||||
|
||||
extern App app;
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
extern Game game;
|
||||
extern Game game;
|
||||
|
||||
static void prevFighter(void);
|
||||
static void nextFighter(void);
|
||||
static int countFighterGuns(Entity *fighter, int type);
|
||||
static int countFighterGuns(Entity *fighter, int type);
|
||||
static void setNumDestroyed(void);
|
||||
|
||||
static int page;
|
||||
static int maxPages;
|
||||
static int numDestroyed;
|
||||
static Widget *prev;
|
||||
static Widget *next;
|
||||
static char *DB_TEXT;
|
||||
static char *PAGE_TEXT;
|
||||
static char *COMMON_TEXT;
|
||||
static char *DESTROYED_TEXT;
|
||||
static char *AFFILIATION_TEXT;
|
||||
static char *ARMOUR_TEXT;
|
||||
static char *SHIELD_TEXT;
|
||||
static char *SPEED_TEXT;
|
||||
static char *MISSILES_TEXT;
|
||||
static char *MISSILE_NUM_TEXT;
|
||||
static int page;
|
||||
static int maxPages;
|
||||
static int numDestroyed;
|
||||
static Widget *prev;
|
||||
static Widget *next;
|
||||
static char *DB_TEXT;
|
||||
static char *PAGE_TEXT;
|
||||
static char *COMMON_TEXT;
|
||||
static char *DESTROYED_TEXT;
|
||||
static char *AFFILIATION_TEXT;
|
||||
static char *ARMOUR_TEXT;
|
||||
static char *SHIELD_TEXT;
|
||||
static char *SPEED_TEXT;
|
||||
static char *MISSILES_TEXT;
|
||||
static char *MISSILE_NUM_TEXT;
|
||||
static const char *gunName[BT_MAX];
|
||||
static Entity **dbFighters;
|
||||
static float rotation;
|
||||
static Entity **dbFighters;
|
||||
static float rotation;
|
||||
|
||||
void initFighterDatabase(void)
|
||||
{
|
||||
|
@ -107,8 +108,8 @@ void doFighterDatabase(void)
|
|||
void drawFighterDatabase(void)
|
||||
{
|
||||
SDL_Rect r;
|
||||
Entity *fighter;
|
||||
int i, y, numCannons;
|
||||
Entity *fighter;
|
||||
int i, y, numCannons;
|
||||
|
||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
|
||||
|
@ -151,7 +152,7 @@ void drawFighterDatabase(void)
|
|||
|
||||
y = 200;
|
||||
|
||||
for (i = 1 ; i < BT_MAX ; i++)
|
||||
for (i = 1; i < BT_MAX; i++)
|
||||
{
|
||||
numCannons = countFighterGuns(fighter, i);
|
||||
if (numCannons > 0)
|
||||
|
@ -186,7 +187,7 @@ static int countFighterGuns(Entity *fighter, int type)
|
|||
|
||||
num = 0;
|
||||
|
||||
for (i = 0 ; i < MAX_FIGHTER_GUNS ; i++)
|
||||
for (i = 0; i < MAX_FIGHTER_GUNS; i++)
|
||||
{
|
||||
if (fighter->guns[i].type == type)
|
||||
{
|
||||
|
@ -213,14 +214,14 @@ static void nextFighter(void)
|
|||
|
||||
static void setNumDestroyed(void)
|
||||
{
|
||||
Tuple *t;
|
||||
Tuple *t;
|
||||
Entity *fighter;
|
||||
|
||||
fighter = dbFighters[page];
|
||||
|
||||
numDestroyed = 0;
|
||||
|
||||
for (t = game.fighterStatHead.next ; t != NULL ; t = t->next)
|
||||
for (t = game.fighterStatHead.next; t != NULL; t = t->next)
|
||||
{
|
||||
if (strcmp(t->key, fighter->name) == 0)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#include "game.h"
|
||||
|
||||
extern Game game;
|
||||
|
|
|
@ -19,15 +19,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "load.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../challenges/challenges.h"
|
||||
|
||||
#include "../battle/fighters.h"
|
||||
#include "../challenges/challenges.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../system/io.h"
|
||||
#include "../galaxy/starSystems.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "load.h"
|
||||
|
||||
extern Game game;
|
||||
|
||||
|
@ -41,7 +42,7 @@ static void loadFighterStats(cJSON *fighterStatsJSON);
|
|||
void loadGame(void)
|
||||
{
|
||||
cJSON *root, *gameJSON;
|
||||
char *text;
|
||||
char *text;
|
||||
|
||||
text = readFile(getSaveFilePath(SAVE_FILENAME));
|
||||
root = cJSON_Parse(text);
|
||||
|
@ -67,9 +68,9 @@ void loadGame(void)
|
|||
static void loadStarSystems(cJSON *starSystemsJSON)
|
||||
{
|
||||
StarSystem *starSystem;
|
||||
cJSON *starSystemJSON;
|
||||
cJSON *starSystemJSON;
|
||||
|
||||
for (starSystemJSON = starSystemsJSON->child ; starSystemJSON != NULL ; starSystemJSON = starSystemJSON->next)
|
||||
for (starSystemJSON = starSystemsJSON->child; starSystemJSON != NULL; starSystemJSON = starSystemJSON->next)
|
||||
{
|
||||
starSystem = getStarSystem(cJSON_GetObjectItem(starSystemJSON, "name")->valuestring);
|
||||
|
||||
|
@ -82,9 +83,9 @@ static void loadStarSystems(cJSON *starSystemsJSON)
|
|||
static void loadMissions(cJSON *missionsJSON)
|
||||
{
|
||||
Mission *mission;
|
||||
cJSON *missionJSON;
|
||||
cJSON *missionJSON;
|
||||
|
||||
for (missionJSON = missionsJSON->child ; missionJSON != NULL ; missionJSON = missionJSON->next)
|
||||
for (missionJSON = missionsJSON->child; missionJSON != NULL; missionJSON = missionJSON->next)
|
||||
{
|
||||
mission = getMission(cJSON_GetObjectItem(missionJSON, "filename")->valuestring);
|
||||
|
||||
|
@ -97,18 +98,18 @@ static void loadMissions(cJSON *missionsJSON)
|
|||
|
||||
static void loadChallenges(cJSON *missionsJSON)
|
||||
{
|
||||
Mission *mission;
|
||||
Mission *mission;
|
||||
Challenge *challenge;
|
||||
cJSON *missionJSON, *challengeJSON;
|
||||
int type, value;
|
||||
cJSON *missionJSON, *challengeJSON;
|
||||
int type, value;
|
||||
|
||||
if (missionsJSON)
|
||||
{
|
||||
for (missionJSON = missionsJSON->child ; missionJSON != NULL ; missionJSON = missionJSON->next)
|
||||
for (missionJSON = missionsJSON->child; missionJSON != NULL; missionJSON = missionJSON->next)
|
||||
{
|
||||
mission = getMission(cJSON_GetObjectItem(missionJSON, "filename")->valuestring);
|
||||
|
||||
for (challengeJSON = cJSON_GetObjectItem(missionJSON, "challenges")->child ; challengeJSON != NULL ; challengeJSON = challengeJSON->next)
|
||||
for (challengeJSON = cJSON_GetObjectItem(missionJSON, "challenges")->child; challengeJSON != NULL; challengeJSON = challengeJSON->next)
|
||||
{
|
||||
type = lookup(cJSON_GetObjectItem(challengeJSON, "type")->valuestring);
|
||||
value = cJSON_GetObjectItem(challengeJSON, "value")->valueint;
|
||||
|
@ -126,10 +127,10 @@ static void loadChallenges(cJSON *missionsJSON)
|
|||
|
||||
static void loadStats(cJSON *statsJSON)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
char *statName;
|
||||
|
||||
for (i = 0 ; i < STAT_MAX ; i++)
|
||||
for (i = 0; i < STAT_MAX; i++)
|
||||
{
|
||||
statName = getLookupName("STAT_", i);
|
||||
|
||||
|
@ -143,11 +144,11 @@ static void loadStats(cJSON *statsJSON)
|
|||
static void loadTrophies(cJSON *trophiesJSON)
|
||||
{
|
||||
Trophy *t;
|
||||
cJSON *trophyJSON;
|
||||
cJSON *trophyJSON;
|
||||
|
||||
if (trophiesJSON)
|
||||
{
|
||||
for (trophyJSON = trophiesJSON->child ; trophyJSON != NULL ; trophyJSON = trophyJSON->next)
|
||||
for (trophyJSON = trophiesJSON->child; trophyJSON != NULL; trophyJSON = trophyJSON->next)
|
||||
{
|
||||
t = getTrophy(cJSON_GetObjectItem(trophyJSON, "id")->valuestring);
|
||||
|
||||
|
@ -171,7 +172,7 @@ static void loadFighterStats(cJSON *fighterStatsJSON)
|
|||
|
||||
if (fighterStatsJSON)
|
||||
{
|
||||
for (fighterStatJSON = fighterStatsJSON->child ; fighterStatJSON != NULL ; fighterStatJSON = fighterStatJSON->next)
|
||||
for (fighterStatJSON = fighterStatsJSON->child; fighterStatJSON != NULL; fighterStatJSON = fighterStatJSON->next)
|
||||
{
|
||||
t = malloc(sizeof(Tuple));
|
||||
memset(t, 0, sizeof(Tuple));
|
||||
|
|
|
@ -18,20 +18,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "options.h"
|
||||
#include <SDL2/SDL_mixer.h>
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#include "../battle/starfield.h"
|
||||
#include "../system/controls.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/init.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "options.h"
|
||||
|
||||
#define SHOW_CONTROLS 1
|
||||
#define SHOW_MAIN 0
|
||||
#define SHOW_CONTROLS 1
|
||||
#define SHOW_MAIN 0
|
||||
|
||||
extern App app;
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
|
||||
static void changeWindowSize(char *value);
|
||||
|
@ -44,7 +46,7 @@ static void drawMain(void);
|
|||
static void controls(void);
|
||||
|
||||
static void (*returnFromOptions)(void);
|
||||
static int show;
|
||||
static int show;
|
||||
static char *OPTIONS_TEXT;
|
||||
static char *RESOLUTION_TEXT;
|
||||
|
||||
|
@ -76,11 +78,11 @@ void initOptions(void (*rtn)(void))
|
|||
OPTIONS_TEXT = _("Options");
|
||||
RESOLUTION_TEXT = _("Note: you must restart the game for window size and fullscreen options to take effect.");
|
||||
|
||||
#if FIXED_RESOLUTION
|
||||
#if FIXED_RESOLUTION
|
||||
getWidget("windowSize", "options")->enabled = 0;
|
||||
getWidget("fullscreen", "options")->enabled = 0;
|
||||
RESOLUTION_TEXT = _("Note: this device does not support changing the screen resolution.");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
returnFromOptions = rtn;
|
||||
|
||||
|
@ -141,14 +143,14 @@ static void drawMain(void)
|
|||
void updateCustomResolutionOption(void)
|
||||
{
|
||||
Widget *w;
|
||||
char value[MAX_NAME_LENGTH];
|
||||
int i;
|
||||
char value[MAX_NAME_LENGTH];
|
||||
int i;
|
||||
|
||||
sprintf(value, "%d x %d", app.winWidth, app.winHeight);
|
||||
|
||||
w = getWidget("windowSize", "options");
|
||||
|
||||
for (i = 0 ; i < w->numOptions - 1 ; i++)
|
||||
for (i = 0; i < w->numOptions - 1; i++)
|
||||
{
|
||||
if (strcmp(w->options[i], value) == 0)
|
||||
{
|
||||
|
@ -204,7 +206,7 @@ static void changeFullscreen(char *value)
|
|||
{
|
||||
app.fullscreen = strcmp(value, "On") == 0;
|
||||
|
||||
SDL_SetWindowFullscreen(app.window, app.fullscreen? SDL_WINDOW_FULLSCREEN : 0);
|
||||
SDL_SetWindowFullscreen(app.window, app.fullscreen ? SDL_WINDOW_FULLSCREEN : 0);
|
||||
}
|
||||
|
||||
static void ok(void)
|
||||
|
|
|
@ -19,23 +19,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "save.h"
|
||||
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "save.h"
|
||||
|
||||
extern Game game;
|
||||
|
||||
static void saveStarSystems(cJSON *gameJSON);
|
||||
static void saveChallenges(cJSON *gameJSON);
|
||||
static void saveStarSystems(cJSON *gameJSON);
|
||||
static void saveChallenges(cJSON *gameJSON);
|
||||
static cJSON *getMissionsJSON(StarSystem *starSystem);
|
||||
static void saveStats(cJSON *gameJSON);
|
||||
static void saveTrophies(cJSON *gameJSON);
|
||||
static void saveFighterStats(cJSON *gameJSON);
|
||||
static void saveStats(cJSON *gameJSON);
|
||||
static void saveTrophies(cJSON *gameJSON);
|
||||
static void saveFighterStats(cJSON *gameJSON);
|
||||
|
||||
void saveGame(void)
|
||||
{
|
||||
char *out;
|
||||
char *out;
|
||||
cJSON *root, *gameJSON;
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Saving Game ...");
|
||||
|
@ -66,12 +67,12 @@ void saveGame(void)
|
|||
|
||||
static void saveStarSystems(cJSON *gameJSON)
|
||||
{
|
||||
cJSON *starSystemJSON, *starSystemsJSON;
|
||||
cJSON *starSystemJSON, *starSystemsJSON;
|
||||
StarSystem *starSystem;
|
||||
|
||||
starSystemsJSON = cJSON_CreateArray();
|
||||
|
||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||
for (starSystem = game.starSystemHead.next; starSystem != NULL; starSystem = starSystem->next)
|
||||
{
|
||||
if (starSystem->totalMissions > 0)
|
||||
{
|
||||
|
@ -90,12 +91,12 @@ static void saveStarSystems(cJSON *gameJSON)
|
|||
|
||||
static cJSON *getMissionsJSON(StarSystem *starSystem)
|
||||
{
|
||||
cJSON *missionJSON, *missionsJSON;
|
||||
cJSON *missionJSON, *missionsJSON;
|
||||
Mission *mission;
|
||||
|
||||
missionsJSON = cJSON_CreateArray();
|
||||
|
||||
for (mission = starSystem->missionHead.next ; mission != NULL ; mission = mission->next)
|
||||
for (mission = starSystem->missionHead.next; mission != NULL; mission = mission->next)
|
||||
{
|
||||
missionJSON = cJSON_CreateObject();
|
||||
|
||||
|
@ -110,14 +111,14 @@ static cJSON *getMissionsJSON(StarSystem *starSystem)
|
|||
|
||||
static void saveChallenges(cJSON *gameJSON)
|
||||
{
|
||||
int i;
|
||||
Mission *mission;
|
||||
int i;
|
||||
Mission *mission;
|
||||
Challenge *c;
|
||||
cJSON *missionsJSON, *missionJSON, *challengesJSON, *challengeJSON;
|
||||
cJSON *missionsJSON, *missionJSON, *challengesJSON, *challengeJSON;
|
||||
|
||||
missionsJSON = cJSON_CreateArray();
|
||||
|
||||
for (mission = game.challengeMissionHead.next ; mission != NULL ; mission = mission->next)
|
||||
for (mission = game.challengeMissionHead.next; mission != NULL; mission = mission->next)
|
||||
{
|
||||
missionJSON = cJSON_CreateObject();
|
||||
|
||||
|
@ -125,7 +126,7 @@ static void saveChallenges(cJSON *gameJSON)
|
|||
|
||||
challengesJSON = cJSON_CreateArray();
|
||||
|
||||
for (i = 0 ; i < MAX_CHALLENGES ; i++)
|
||||
for (i = 0; i < MAX_CHALLENGES; i++)
|
||||
{
|
||||
c = mission->challengeData.challenges[i];
|
||||
|
||||
|
@ -154,7 +155,7 @@ static void saveStats(cJSON *gameJSON)
|
|||
|
||||
cJSON *stats = cJSON_CreateObject();
|
||||
|
||||
for (i = 0 ; i < STAT_MAX ; i++)
|
||||
for (i = 0; i < STAT_MAX; i++)
|
||||
{
|
||||
cJSON_AddNumberToObject(stats, getLookupName("STAT_", i), game.stats[i]);
|
||||
}
|
||||
|
@ -165,11 +166,11 @@ static void saveStats(cJSON *gameJSON)
|
|||
static void saveTrophies(cJSON *gameJSON)
|
||||
{
|
||||
Trophy *t;
|
||||
cJSON *trophiesJSON, *trophyJSON;
|
||||
cJSON *trophiesJSON, *trophyJSON;
|
||||
|
||||
trophiesJSON = cJSON_CreateArray();
|
||||
|
||||
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
||||
for (t = game.trophyHead.next; t != NULL; t = t->next)
|
||||
{
|
||||
if (t->awarded)
|
||||
{
|
||||
|
@ -192,7 +193,7 @@ static void saveFighterStats(cJSON *gameJSON)
|
|||
|
||||
fighterStatsJSON = cJSON_CreateArray();
|
||||
|
||||
for (t = game.fighterStatHead.next ; t != NULL ; t = t->next)
|
||||
for (t = game.fighterStatHead.next; t != NULL; t = t->next)
|
||||
{
|
||||
fighterStatJSON = cJSON_CreateObject();
|
||||
|
||||
|
|
|
@ -19,28 +19,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "stats.h"
|
||||
|
||||
#include "../system/text.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "stats.h"
|
||||
|
||||
#define STATS_PER_PAGE 9
|
||||
#define STATS_PER_PAGE 9
|
||||
|
||||
extern App app;
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
extern Game game;
|
||||
extern Game game;
|
||||
|
||||
static void prevPage(void);
|
||||
static void nextPage(void);
|
||||
static void calculatePercentComplete(void);
|
||||
|
||||
static char *statDescription[STAT_MAX];
|
||||
static int page;
|
||||
static float maxPages;
|
||||
static char *statDescription[STAT_MAX];
|
||||
static int page;
|
||||
static float maxPages;
|
||||
static Widget *prev;
|
||||
static Widget *next;
|
||||
static char *STATS_TEXT;
|
||||
static char *PAGE_TEXT;
|
||||
static char *STATS_TEXT;
|
||||
static char *PAGE_TEXT;
|
||||
|
||||
void initStats(void)
|
||||
{
|
||||
|
@ -112,12 +113,12 @@ void initStatsDisplay(void)
|
|||
static void calculatePercentComplete(void)
|
||||
{
|
||||
StarSystem *starSystem;
|
||||
Mission *mission;
|
||||
int completed, total;
|
||||
Mission *mission;
|
||||
int completed, total;
|
||||
|
||||
completed = total = 0;
|
||||
|
||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||
for (starSystem = game.starSystemHead.next; starSystem != NULL; starSystem = starSystem->next)
|
||||
{
|
||||
if (starSystem->type == SS_NORMAL)
|
||||
{
|
||||
|
@ -126,7 +127,7 @@ static void calculatePercentComplete(void)
|
|||
}
|
||||
}
|
||||
|
||||
for (mission = game.challengeMissionHead.next ; mission != NULL ; mission = mission->next)
|
||||
for (mission = game.challengeMissionHead.next; mission != NULL; mission = mission->next)
|
||||
{
|
||||
completed += mission->completedChallenges;
|
||||
total += mission->totalChallenges;
|
||||
|
@ -137,7 +138,7 @@ static void calculatePercentComplete(void)
|
|||
|
||||
void drawStats(void)
|
||||
{
|
||||
int i, y, startIndex;
|
||||
int i, y, startIndex;
|
||||
SDL_Rect r;
|
||||
|
||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
||||
|
@ -168,7 +169,7 @@ void drawStats(void)
|
|||
|
||||
startIndex = (page * STATS_PER_PAGE);
|
||||
|
||||
for (i = startIndex ; i < startIndex + STATS_PER_PAGE ; i++)
|
||||
for (i = startIndex; i < startIndex + STATS_PER_PAGE; i++)
|
||||
{
|
||||
if (i < STAT_TIME)
|
||||
{
|
||||
|
|
|
@ -19,39 +19,40 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "title.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../system/transition.h"
|
||||
#include "../battle/starfield.h"
|
||||
#include "../game/credits.h"
|
||||
#include "../system/input.h"
|
||||
#include "../game/stats.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../challenges/challengeHome.h"
|
||||
|
||||
#include "../battle/battle.h"
|
||||
#include "../galaxy/galacticMap.h"
|
||||
#include "../game/options.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../game/fighterDatabase.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../battle/effects.h"
|
||||
#include "../system/text.h"
|
||||
#include "../battle/starfield.h"
|
||||
#include "../challenges/challengeHome.h"
|
||||
#include "../galaxy/galacticMap.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../game/credits.h"
|
||||
#include "../game/fighterDatabase.h"
|
||||
#include "../game/options.h"
|
||||
#include "../game/stats.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/input.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/textures.h"
|
||||
#include "../system/transition.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "title.h"
|
||||
|
||||
#define NUM_FIGHTERS 12
|
||||
#define SHOW_FIGHTER_DB 4
|
||||
#define SHOW_OPTIONS 2
|
||||
#define SHOW_STATS 1
|
||||
#define SHOW_TITLE 0
|
||||
#define SHOW_TROPHIES 3
|
||||
#define NUM_FIGHTERS 12
|
||||
#define SHOW_FIGHTER_DB 4
|
||||
#define SHOW_OPTIONS 2
|
||||
#define SHOW_STATS 1
|
||||
#define SHOW_TITLE 0
|
||||
#define SHOW_TROPHIES 3
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Entity *self;
|
||||
extern Game game;
|
||||
extern Game game;
|
||||
|
||||
static void logic(void);
|
||||
static void draw(void);
|
||||
|
@ -71,13 +72,13 @@ static void quit(void);
|
|||
static void returnFromOptions(void);
|
||||
|
||||
static SDL_Texture *background;
|
||||
static AtlasImage *logo[2];
|
||||
static AtlasImage *pandoranWar;
|
||||
static AtlasImage *earthTexture;
|
||||
static PointF earth;
|
||||
static Entity fighters[NUM_FIGHTERS];
|
||||
static const char *fighterTextures[] = {"gfx/fighters/firefly.png", "gfx/fighters/hammerhead.png", "gfx/fighters/hyena.png", "gfx/fighters/lynx.png", "gfx/fighters/kingfisher.png", "gfx/fighters/leopard.png", "gfx/fighters/nymph.png", "gfx/fighters/ray.png", "gfx/fighters/rook.png", "gfx/fighters/taf.png"};
|
||||
static int show;
|
||||
static AtlasImage *logo[2];
|
||||
static AtlasImage *pandoranWar;
|
||||
static AtlasImage *earthTexture;
|
||||
static PointF earth;
|
||||
static Entity fighters[NUM_FIGHTERS];
|
||||
static const char *fighterTextures[] = {"gfx/fighters/firefly.png", "gfx/fighters/hammerhead.png", "gfx/fighters/hyena.png", "gfx/fighters/lynx.png", "gfx/fighters/kingfisher.png", "gfx/fighters/leopard.png", "gfx/fighters/nymph.png", "gfx/fighters/ray.png", "gfx/fighters/rook.png", "gfx/fighters/taf.png"};
|
||||
static int show;
|
||||
|
||||
void initTitle(void)
|
||||
{
|
||||
|
@ -89,7 +90,7 @@ void initTitle(void)
|
|||
app.delegate.draw = &draw;
|
||||
memset(&app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS);
|
||||
|
||||
battle.camera.x = battle.camera.y = 0;
|
||||
battle.camera.x = battle.camera.y = 0;
|
||||
|
||||
destroyBattle();
|
||||
|
||||
|
@ -137,11 +138,11 @@ static void initFighters(void)
|
|||
{
|
||||
int i, numTextures;
|
||||
|
||||
numTextures = sizeof(fighterTextures) / sizeof(char*);
|
||||
numTextures = sizeof(fighterTextures) / sizeof(char *);
|
||||
|
||||
memset(&fighters, 0, sizeof(Entity) * NUM_FIGHTERS);
|
||||
|
||||
for (i = 0 ; i < NUM_FIGHTERS ; i++)
|
||||
for (i = 0; i < NUM_FIGHTERS; i++)
|
||||
{
|
||||
fighters[i].x = rand() % (app.winWidth - 32);
|
||||
fighters[i].y = app.winHeight + (rand() % app.winHeight);
|
||||
|
@ -184,9 +185,9 @@ static void doFighters(void)
|
|||
{
|
||||
int i, numTextures;
|
||||
|
||||
numTextures = sizeof(fighterTextures) / sizeof(char*);
|
||||
numTextures = sizeof(fighterTextures) / sizeof(char *);
|
||||
|
||||
for (i = 0 ; i < NUM_FIGHTERS ; i++)
|
||||
for (i = 0; i < NUM_FIGHTERS; i++)
|
||||
{
|
||||
self = &fighters[i];
|
||||
|
||||
|
@ -263,7 +264,7 @@ static void drawFighters(void)
|
|||
|
||||
setAtlasColor(255, 255, 255, 255);
|
||||
|
||||
for (i = 0 ; i < NUM_FIGHTERS ; i++)
|
||||
for (i = 0; i < NUM_FIGHTERS; i++)
|
||||
{
|
||||
blit(fighters[i].texture, fighters[i].x, fighters[i].y, 1);
|
||||
}
|
||||
|
|
|
@ -18,27 +18,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "trophies.h"
|
||||
#include <time.h>
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#include "../battle/entities.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../battle/entities.h"
|
||||
#include "trophies.h"
|
||||
|
||||
#define TROPHIES_PER_PAGE 4
|
||||
#define TROPHIES_PER_PAGE 4
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Entity *player;
|
||||
extern Game game;
|
||||
extern Game game;
|
||||
|
||||
static void prevPage(void);
|
||||
static void nextPage(void);
|
||||
|
@ -47,24 +49,24 @@ static void resetAlert(void);
|
|||
static void setSparkleColor(Trophy *t);
|
||||
static void nextAlert(void);
|
||||
|
||||
static Trophy *alertTrophy;
|
||||
static Trophy *alertTrophy;
|
||||
static AtlasImage *trophyIcons[TROPHY_MAX];
|
||||
static AtlasImage *sparkle;
|
||||
static AtlasImage *alertSphere;
|
||||
static SDL_Rect alertRect;
|
||||
static int alertTimer;
|
||||
static int page;
|
||||
static int awarded;
|
||||
static int total;
|
||||
static int boxWidth;
|
||||
static float sparkleAngle;
|
||||
static float maxPages;
|
||||
static Widget *prev;
|
||||
static Widget *next;
|
||||
static char *TROPHIES_TEXT;
|
||||
static char *AWARDED_TEXT;
|
||||
static char *PAGE_TEXT;
|
||||
static char *HIDDEN_TEXT;
|
||||
static SDL_Rect alertRect;
|
||||
static int alertTimer;
|
||||
static int page;
|
||||
static int awarded;
|
||||
static int total;
|
||||
static int boxWidth;
|
||||
static float sparkleAngle;
|
||||
static float maxPages;
|
||||
static Widget *prev;
|
||||
static Widget *next;
|
||||
static char *TROPHIES_TEXT;
|
||||
static char *AWARDED_TEXT;
|
||||
static char *PAGE_TEXT;
|
||||
static char *HIDDEN_TEXT;
|
||||
|
||||
void initTrophies(void)
|
||||
{
|
||||
|
@ -93,12 +95,12 @@ void initTrophies(void)
|
|||
|
||||
void initTrophiesDisplay(void)
|
||||
{
|
||||
int w, h;
|
||||
int w, h;
|
||||
Trophy *t;
|
||||
|
||||
boxWidth = total = awarded = 0;
|
||||
|
||||
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
||||
for (t = game.trophyHead.next; t != NULL; t = t->next)
|
||||
{
|
||||
total++;
|
||||
|
||||
|
@ -149,9 +151,9 @@ static void prevPage(void)
|
|||
|
||||
void drawTrophies(void)
|
||||
{
|
||||
Trophy *t;
|
||||
Trophy *t;
|
||||
SDL_Rect r;
|
||||
int start, end, i, x, y;
|
||||
int start, end, i, x, y;
|
||||
|
||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
|
||||
|
@ -183,7 +185,7 @@ void drawTrophies(void)
|
|||
end = start + TROPHIES_PER_PAGE;
|
||||
i = 0;
|
||||
|
||||
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
||||
for (t = game.trophyHead.next; t != NULL; t = t->next)
|
||||
{
|
||||
if (i >= start && i < end)
|
||||
{
|
||||
|
@ -230,11 +232,11 @@ void drawTrophies(void)
|
|||
void awardTrophy(char *id)
|
||||
{
|
||||
Trophy *t;
|
||||
int numRemaining;
|
||||
int numRemaining;
|
||||
|
||||
numRemaining = 0;
|
||||
|
||||
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
||||
for (t = game.trophyHead.next; t != NULL; t = t->next)
|
||||
{
|
||||
if (!t->awarded && strcmp(t->id, id) == 0)
|
||||
{
|
||||
|
@ -290,10 +292,10 @@ void doTrophyAlerts(void)
|
|||
|
||||
static void nextAlert(void)
|
||||
{
|
||||
int w, h;
|
||||
int w, h;
|
||||
Trophy *t;
|
||||
|
||||
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
||||
for (t = game.trophyHead.next; t != NULL; t = t->next)
|
||||
{
|
||||
if (t->notify)
|
||||
{
|
||||
|
@ -356,7 +358,7 @@ Trophy *getTrophy(char *id)
|
|||
{
|
||||
Trophy *t;
|
||||
|
||||
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
||||
for (t = game.trophyHead.next; t != NULL; t = t->next)
|
||||
{
|
||||
if (strcmp(t->id, id) == 0)
|
||||
{
|
||||
|
@ -369,10 +371,10 @@ Trophy *getTrophy(char *id)
|
|||
|
||||
static void loadTrophyData(char *filename)
|
||||
{
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
Trophy *t, *tail;
|
||||
int count[TROPHY_MAX];
|
||||
int count[TROPHY_MAX];
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Loading %s", filename);
|
||||
|
||||
|
@ -383,7 +385,7 @@ static void loadTrophyData(char *filename)
|
|||
|
||||
memset(count, 0, sizeof(int) * TROPHY_MAX);
|
||||
|
||||
for (node = root->child ; node != NULL ; node = node->next)
|
||||
for (node = root->child; node != NULL; node = node->next)
|
||||
{
|
||||
if (cJSON_GetObjectItem(node, "id")->valuestring[0] != '_')
|
||||
{
|
||||
|
@ -422,9 +424,9 @@ static void loadTrophyData(char *filename)
|
|||
void awardStatsTrophies(void)
|
||||
{
|
||||
Trophy *t;
|
||||
Tuple *tp;
|
||||
Tuple *tp;
|
||||
|
||||
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
||||
for (t = game.trophyHead.next; t != NULL; t = t->next)
|
||||
{
|
||||
if (t->stat != -1 && !t->awarded && (game.stats[t->stat] + battle.stats[t->stat]) >= t->statValue)
|
||||
{
|
||||
|
@ -433,7 +435,7 @@ void awardStatsTrophies(void)
|
|||
}
|
||||
|
||||
/* check to see if we've destroyed one of each common starfighter */
|
||||
for (tp = game.fighterStatHead.next ; tp != NULL ; tp = tp->next)
|
||||
for (tp = game.fighterStatHead.next; tp != NULL; tp = tp->next)
|
||||
{
|
||||
if (tp->value == 0)
|
||||
{
|
||||
|
@ -446,9 +448,9 @@ void awardStatsTrophies(void)
|
|||
|
||||
void awardCampaignTrophies(void)
|
||||
{
|
||||
char trophyId[MAX_NAME_LENGTH * 2];
|
||||
char name[MAX_NAME_LENGTH];
|
||||
int i, len;
|
||||
char trophyId[MAX_NAME_LENGTH * 2];
|
||||
char name[MAX_NAME_LENGTH];
|
||||
int i, len;
|
||||
StarSystem *starSystem;
|
||||
|
||||
if (game.completedMissions)
|
||||
|
@ -457,7 +459,7 @@ void awardCampaignTrophies(void)
|
|||
}
|
||||
|
||||
/* check if all star system missions are completed */
|
||||
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
|
||||
for (starSystem = game.starSystemHead.next; starSystem != NULL; starSystem = starSystem->next)
|
||||
{
|
||||
if (starSystem->totalMissions && starSystem->completedMissions == starSystem->totalMissions)
|
||||
{
|
||||
|
@ -465,7 +467,7 @@ void awardCampaignTrophies(void)
|
|||
|
||||
len = strlen(starSystem->name);
|
||||
|
||||
for (i = 0 ; i < len ; i++)
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
name[i] = toupper(starSystem->name[i]);
|
||||
}
|
||||
|
@ -479,7 +481,7 @@ void awardCampaignTrophies(void)
|
|||
void awardChallengeTrophies(void)
|
||||
{
|
||||
char trophyId[MAX_NAME_LENGTH];
|
||||
int completed;
|
||||
int completed;
|
||||
|
||||
/* check % of challenges completed - 25% increments*/
|
||||
completed = (getPercent(game.completedChallenges, game.totalChallenges) / 25) * 25;
|
||||
|
|
|
@ -18,15 +18,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void awardCraftTrophy(void);
|
||||
void awardPostMissionTrophies(void);
|
||||
void awardChallengeTrophies(void);
|
||||
void awardCampaignTrophies(void);
|
||||
void awardStatsTrophies(void);
|
||||
void awardCraftTrophy(void);
|
||||
void awardPostMissionTrophies(void);
|
||||
void awardChallengeTrophies(void);
|
||||
void awardCampaignTrophies(void);
|
||||
void awardStatsTrophies(void);
|
||||
Trophy *getTrophy(char *id);
|
||||
void drawTrophyAlert(void);
|
||||
void doTrophyAlerts(void);
|
||||
void awardTrophy(char *id);
|
||||
void drawTrophies(void);
|
||||
void initTrophiesDisplay(void);
|
||||
void initTrophies(void);
|
||||
void drawTrophyAlert(void);
|
||||
void doTrophyAlerts(void);
|
||||
void awardTrophy(char *id);
|
||||
void drawTrophies(void);
|
||||
void initTrophiesDisplay(void);
|
||||
void initTrophies(void);
|
||||
|
|
1065
src/json/cJSON.c
1065
src/json/cJSON.c
File diff suppressed because it is too large
Load Diff
172
src/json/cJSON.h
172
src/json/cJSON.h
|
@ -29,117 +29,119 @@ extern "C"
|
|||
#endif
|
||||
|
||||
/* cJSON Types: */
|
||||
#define cJSON_False 0
|
||||
#define cJSON_True 1
|
||||
#define cJSON_NULL 2
|
||||
#define cJSON_False 0
|
||||
#define cJSON_True 1
|
||||
#define cJSON_NULL 2
|
||||
#define cJSON_Number 3
|
||||
#define cJSON_String 4
|
||||
#define cJSON_Array 5
|
||||
#define cJSON_Array 5
|
||||
#define cJSON_Object 6
|
||||
|
||||
#define cJSON_IsReference 256
|
||||
#define cJSON_IsReference 256
|
||||
#define cJSON_StringIsConst 512
|
||||
|
||||
/* The cJSON structure: */
|
||||
typedef struct cJSON {
|
||||
struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||
/* The cJSON structure: */
|
||||
typedef struct cJSON
|
||||
{
|
||||
struct cJSON *next, *prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||
struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||
|
||||
int type; /* The type of the item, as above. */
|
||||
int type; /* The type of the item, as above. */
|
||||
|
||||
char *valuestring; /* The item's string, if type==cJSON_String */
|
||||
int valueint; /* The item's number, if type==cJSON_Number */
|
||||
double valuedouble; /* The item's number, if type==cJSON_Number */
|
||||
char *valuestring; /* The item's string, if type==cJSON_String */
|
||||
int valueint; /* The item's number, if type==cJSON_Number */
|
||||
double valuedouble; /* The item's number, if type==cJSON_Number */
|
||||
|
||||
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||
} cJSON;
|
||||
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||
} cJSON;
|
||||
|
||||
typedef struct cJSON_Hooks {
|
||||
void *(*malloc_fn)(size_t sz);
|
||||
void (*free_fn)(void *ptr);
|
||||
} cJSON_Hooks;
|
||||
typedef struct cJSON_Hooks
|
||||
{
|
||||
void *(*malloc_fn)(size_t sz);
|
||||
void (*free_fn)(void *ptr);
|
||||
} cJSON_Hooks;
|
||||
|
||||
/* Supply malloc, realloc and free functions to cJSON */
|
||||
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||
/* Supply malloc, realloc and free functions to cJSON */
|
||||
extern void cJSON_InitHooks(cJSON_Hooks *hooks);
|
||||
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
|
||||
extern cJSON *cJSON_Parse(const char *value);
|
||||
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
|
||||
extern char *cJSON_Print(cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
|
||||
extern char *cJSON_PrintUnformatted(cJSON *item);
|
||||
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
||||
extern char *cJSON_PrintBuffered(cJSON *item,int prebuffer,int fmt);
|
||||
/* Delete a cJSON entity and all subentities. */
|
||||
extern void cJSON_Delete(cJSON *c);
|
||||
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
|
||||
extern cJSON *cJSON_Parse(const char *value);
|
||||
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
|
||||
extern char *cJSON_Print(cJSON *item);
|
||||
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
|
||||
extern char *cJSON_PrintUnformatted(cJSON *item);
|
||||
/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
|
||||
extern char *cJSON_PrintBuffered(cJSON *item, int prebuffer, int fmt);
|
||||
/* Delete a cJSON entity and all subentities. */
|
||||
extern void cJSON_Delete(cJSON *c);
|
||||
|
||||
/* Returns the number of items in an array (or object). */
|
||||
extern int cJSON_GetArraySize(cJSON *array);
|
||||
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
|
||||
extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
|
||||
/* Returns the number of items in an array (or object). */
|
||||
extern int cJSON_GetArraySize(cJSON *array);
|
||||
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
|
||||
extern cJSON *cJSON_GetArrayItem(cJSON *array, int item);
|
||||
/* Get item "string" from object. Case insensitive. */
|
||||
extern cJSON *cJSON_GetObjectItem(cJSON *object, const char *string);
|
||||
|
||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||
extern const char *cJSON_GetErrorPtr(void);
|
||||
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||
extern const char *cJSON_GetErrorPtr(void);
|
||||
|
||||
/* These calls create a cJSON item of the appropriate type. */
|
||||
extern cJSON *cJSON_CreateNull(void);
|
||||
extern cJSON *cJSON_CreateTrue(void);
|
||||
extern cJSON *cJSON_CreateFalse(void);
|
||||
extern cJSON *cJSON_CreateBool(int b);
|
||||
extern cJSON *cJSON_CreateNumber(double num);
|
||||
extern cJSON *cJSON_CreateString(const char *string);
|
||||
extern cJSON *cJSON_CreateArray(void);
|
||||
extern cJSON *cJSON_CreateObject(void);
|
||||
/* These calls create a cJSON item of the appropriate type. */
|
||||
extern cJSON *cJSON_CreateNull(void);
|
||||
extern cJSON *cJSON_CreateTrue(void);
|
||||
extern cJSON *cJSON_CreateFalse(void);
|
||||
extern cJSON *cJSON_CreateBool(int b);
|
||||
extern cJSON *cJSON_CreateNumber(double num);
|
||||
extern cJSON *cJSON_CreateString(const char *string);
|
||||
extern cJSON *cJSON_CreateArray(void);
|
||||
extern cJSON *cJSON_CreateObject(void);
|
||||
|
||||
/* These utilities create an Array of count items. */
|
||||
extern cJSON *cJSON_CreateIntArray(const int *numbers,int count);
|
||||
extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count);
|
||||
extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count);
|
||||
extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
|
||||
/* These utilities create an Array of count items. */
|
||||
extern cJSON *cJSON_CreateIntArray(const int *numbers, int count);
|
||||
extern cJSON *cJSON_CreateFloatArray(const float *numbers, int count);
|
||||
extern cJSON *cJSON_CreateDoubleArray(const double *numbers, int count);
|
||||
extern cJSON *cJSON_CreateStringArray(const char **strings, int count);
|
||||
|
||||
/* Append item to the specified array/object. */
|
||||
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
|
||||
extern void cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item); /* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object */
|
||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
|
||||
/* Append item to the specified array/object. */
|
||||
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||
extern void cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
|
||||
extern void cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item); /* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object */
|
||||
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||
extern void cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
|
||||
|
||||
/* Remove/Detatch items from Arrays/Objects. */
|
||||
extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
|
||||
extern void cJSON_DeleteItemFromArray(cJSON *array,int which);
|
||||
extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
|
||||
extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string);
|
||||
/* Remove/Detatch items from Arrays/Objects. */
|
||||
extern cJSON *cJSON_DetachItemFromArray(cJSON *array, int which);
|
||||
extern void cJSON_DeleteItemFromArray(cJSON *array, int which);
|
||||
extern cJSON *cJSON_DetachItemFromObject(cJSON *object, const char *string);
|
||||
extern void cJSON_DeleteItemFromObject(cJSON *object, const char *string);
|
||||
|
||||
/* Update array items. */
|
||||
extern void cJSON_InsertItemInArray(cJSON *array,int which,cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
|
||||
extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||
/* Update array items. */
|
||||
extern void cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); /* Shifts pre-existing items to the right. */
|
||||
extern void cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
|
||||
extern void cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem);
|
||||
|
||||
/* Duplicate a cJSON item */
|
||||
extern cJSON *cJSON_Duplicate(cJSON *item,int recurse);
|
||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||
need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||
The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||
/* Duplicate a cJSON item */
|
||||
extern cJSON *cJSON_Duplicate(cJSON *item, int recurse);
|
||||
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||
need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||
The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated);
|
||||
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||
extern cJSON *cJSON_ParseWithOpts(const char *value, const char **return_parse_end, int require_null_terminated);
|
||||
|
||||
extern void cJSON_Minify(char *json);
|
||||
extern void cJSON_Minify(char *json);
|
||||
|
||||
/* Macros for creating things quickly. */
|
||||
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
|
||||
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
|
||||
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
|
||||
#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
|
||||
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
|
||||
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
|
||||
#define cJSON_AddNullToObject(object, name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
|
||||
#define cJSON_AddTrueToObject(object, name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
|
||||
#define cJSON_AddFalseToObject(object, name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
|
||||
#define cJSON_AddBoolToObject(object, name, b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
|
||||
#define cJSON_AddNumberToObject(object, name, n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
|
||||
#define cJSON_AddStringToObject(object, name, s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
|
||||
|
||||
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||
#define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
|
||||
#define cJSON_SetNumberValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
|
||||
#define cJSON_SetIntValue(object, val) ((object) ? (object)->valueint = (object)->valuedouble = (val) : (val))
|
||||
#define cJSON_SetNumberValue(object, val) ((object) ? (object)->valueint = (object)->valuedouble = (val) : (val))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
42
src/main.c
42
src/main.c
|
@ -18,32 +18,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "main.h"
|
||||
#include <time.h>
|
||||
#include "game/load.h"
|
||||
#include "system/lookup.h"
|
||||
#include "system/draw.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "game/credits.h"
|
||||
#include "system/input.h"
|
||||
#include "system/controls.h"
|
||||
#include "game/load.h"
|
||||
#include "game/save.h"
|
||||
#include "game/title.h"
|
||||
#include "game/trophies.h"
|
||||
#include "main.h"
|
||||
#include "plat/win32/win32Init.h"
|
||||
#include "system/controls.h"
|
||||
#include "system/dev.h"
|
||||
#include "system/draw.h"
|
||||
#include "system/init.h"
|
||||
#include "system/input.h"
|
||||
#include "system/io.h"
|
||||
#include "system/lookup.h"
|
||||
#include "system/modalDialog.h"
|
||||
#include "test/testMission.h"
|
||||
#include "game/save.h"
|
||||
#include "system/io.h"
|
||||
#include "system/dev.h"
|
||||
#include "system/init.h"
|
||||
#include "plat/win32/win32Init.h"
|
||||
|
||||
App app;
|
||||
Battle battle;
|
||||
Colors colors;
|
||||
Dev dev;
|
||||
App app;
|
||||
Battle battle;
|
||||
Colors colors;
|
||||
Dev dev;
|
||||
Entity *player;
|
||||
Entity *self;
|
||||
Game game;
|
||||
Game game;
|
||||
|
||||
static void handleMissionArgs(int argc, char *argv[]);
|
||||
static void handleLoggingArgs(int argc, char *argv[]);
|
||||
|
@ -51,7 +53,7 @@ static void capFrameRate(long *then, float *remainder);
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
long then, lastFrameTime, frames;
|
||||
long then, lastFrameTime, frames;
|
||||
float remainder;
|
||||
|
||||
memset(&app, 0, sizeof(App));
|
||||
|
@ -191,7 +193,7 @@ static void handleLoggingArgs(int argc, char *argv[])
|
|||
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN);
|
||||
|
||||
for (i = 1 ; i < argc ; i++)
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "-debug") == 0)
|
||||
{
|
||||
|
@ -213,7 +215,7 @@ static void handleMissionArgs(int argc, char *argv[])
|
|||
|
||||
showCredits = testingMission = 0;
|
||||
|
||||
for (i = 1 ; i < argc ; i++)
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
/* assume this is filename for testing */
|
||||
if (strcmp(argv[i], "-mission") == 0)
|
||||
|
|
|
@ -18,12 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "../../common.h"
|
||||
#include "unixInit.h"
|
||||
#include <sys/stat.h>
|
||||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../../common.h"
|
||||
|
||||
#include "unixInit.h"
|
||||
|
||||
extern App app;
|
||||
extern Dev dev;
|
||||
|
@ -31,7 +33,7 @@ extern Dev dev;
|
|||
void createSaveFolder(void)
|
||||
{
|
||||
char *userHome;
|
||||
char dir[MAX_FILENAME_LENGTH];
|
||||
char dir[MAX_FILENAME_LENGTH];
|
||||
|
||||
userHome = getenv("HOME");
|
||||
|
||||
|
@ -44,7 +46,7 @@ void createSaveFolder(void)
|
|||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "User home = %s", userHome);
|
||||
|
||||
sprintf(dir, "%s/.local/share/tbftss", userHome);
|
||||
if (mkdir(dir, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH) != 0 && errno != EEXIST)
|
||||
if (mkdir(dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0 && errno != EEXIST)
|
||||
{
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "Failed to create save dir '%s'. Will save to current dir.", dir);
|
||||
return;
|
||||
|
@ -55,7 +57,7 @@ void createSaveFolder(void)
|
|||
|
||||
void createScreenshotFolder(void)
|
||||
{
|
||||
mkdir("/tmp/tbftss", S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH);
|
||||
mkdir("/tmp/tbftss", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
|
||||
dev.screenshotFolder = "/tmp/tbftss";
|
||||
}
|
||||
|
|
|
@ -18,11 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "../../common.h"
|
||||
#include "win32Init.h"
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "../../common.h"
|
||||
|
||||
#include "win32Init.h"
|
||||
|
||||
extern App app;
|
||||
extern Dev dev;
|
||||
|
@ -30,7 +32,7 @@ extern Dev dev;
|
|||
void createSaveFolder(void)
|
||||
{
|
||||
char *userHome;
|
||||
char dir[MAX_FILENAME_LENGTH];
|
||||
char dir[MAX_FILENAME_LENGTH];
|
||||
|
||||
userHome = getenv("USERPROFILE");
|
||||
|
||||
|
|
812
src/structs.h
812
src/structs.h
|
@ -18,66 +18,71 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
typedef struct Texture Texture;
|
||||
typedef struct Lookup Lookup;
|
||||
typedef struct Weapon Weapon;
|
||||
typedef struct Quadtree Quadtree;
|
||||
typedef struct Entity Entity;
|
||||
typedef struct Bullet Bullet;
|
||||
typedef struct Debris Debris;
|
||||
typedef struct Effect Effect;
|
||||
typedef struct Spawner Spawner;
|
||||
typedef struct Objective Objective;
|
||||
typedef struct StarSystem StarSystem;
|
||||
typedef struct Challenge Challenge;
|
||||
typedef struct Mission Mission;
|
||||
typedef struct Pulse Pulse;
|
||||
typedef struct Widget Widget;
|
||||
typedef struct HudMessage HudMessage;
|
||||
typedef struct MessageBox MessageBox;
|
||||
typedef struct Texture Texture;
|
||||
typedef struct Lookup Lookup;
|
||||
typedef struct Weapon Weapon;
|
||||
typedef struct Quadtree Quadtree;
|
||||
typedef struct Entity Entity;
|
||||
typedef struct Bullet Bullet;
|
||||
typedef struct Debris Debris;
|
||||
typedef struct Effect Effect;
|
||||
typedef struct Spawner Spawner;
|
||||
typedef struct Objective Objective;
|
||||
typedef struct StarSystem StarSystem;
|
||||
typedef struct Challenge Challenge;
|
||||
typedef struct Mission Mission;
|
||||
typedef struct Pulse Pulse;
|
||||
typedef struct Widget Widget;
|
||||
typedef struct HudMessage HudMessage;
|
||||
typedef struct MessageBox MessageBox;
|
||||
typedef struct ScriptRunner ScriptRunner;
|
||||
typedef struct Location Location;
|
||||
typedef struct Bucket Bucket;
|
||||
typedef struct Trophy Trophy;
|
||||
typedef struct Tuple Tuple;
|
||||
typedef struct Credit Credit;
|
||||
typedef struct AtlasImage AtlasImage;
|
||||
typedef struct Font Font;
|
||||
typedef struct Location Location;
|
||||
typedef struct Bucket Bucket;
|
||||
typedef struct Trophy Trophy;
|
||||
typedef struct Tuple Tuple;
|
||||
typedef struct Credit Credit;
|
||||
typedef struct AtlasImage AtlasImage;
|
||||
typedef struct Font Font;
|
||||
|
||||
typedef struct {
|
||||
int debug;
|
||||
int takeScreenshots;
|
||||
typedef struct
|
||||
{
|
||||
int debug;
|
||||
int takeScreenshots;
|
||||
char *screenshotFolder;
|
||||
int noAIWeapons;
|
||||
int showFPS;
|
||||
int playerImmortal;
|
||||
int playerUnlimitedMissiles;
|
||||
int noEntityActions;
|
||||
int allImmortal;
|
||||
int fps;
|
||||
int noAIWeapons;
|
||||
int showFPS;
|
||||
int playerImmortal;
|
||||
int playerUnlimitedMissiles;
|
||||
int noEntityActions;
|
||||
int allImmortal;
|
||||
int fps;
|
||||
} Dev;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
} PointF;
|
||||
|
||||
struct Texture {
|
||||
char name[MAX_DESCRIPTION_LENGTH];
|
||||
long hash;
|
||||
long ttl;
|
||||
struct Texture
|
||||
{
|
||||
char name[MAX_DESCRIPTION_LENGTH];
|
||||
long hash;
|
||||
long ttl;
|
||||
SDL_Texture *texture;
|
||||
Texture *next;
|
||||
Texture *next;
|
||||
};
|
||||
|
||||
struct AtlasImage {
|
||||
char filename[MAX_FILENAME_LENGTH];
|
||||
SDL_Rect rect;
|
||||
struct AtlasImage
|
||||
{
|
||||
char filename[MAX_FILENAME_LENGTH];
|
||||
SDL_Rect rect;
|
||||
SDL_Texture *texture;
|
||||
AtlasImage *next;
|
||||
AtlasImage *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
void (*logic)(void);
|
||||
void (*draw)(void);
|
||||
void (*handleClick)(int x, int y, int btn);
|
||||
|
@ -85,18 +90,21 @@ typedef struct {
|
|||
void (*handleMouseUp)(int x, int y, int btn);
|
||||
} Delegate;
|
||||
|
||||
typedef struct {
|
||||
int type;
|
||||
typedef struct
|
||||
{
|
||||
int type;
|
||||
char message[MAX_DESCRIPTION_LENGTH];
|
||||
} ModalDialog;
|
||||
|
||||
struct Lookup {
|
||||
char name[MAX_NAME_LENGTH];
|
||||
long value;
|
||||
struct Lookup
|
||||
{
|
||||
char name[MAX_NAME_LENGTH];
|
||||
long value;
|
||||
Lookup *next;
|
||||
};
|
||||
|
||||
struct Weapon {
|
||||
struct Weapon
|
||||
{
|
||||
int type;
|
||||
int ammo;
|
||||
int maxAmmo;
|
||||
|
@ -104,361 +112,382 @@ struct Weapon {
|
|||
int y;
|
||||
};
|
||||
|
||||
struct Entity {
|
||||
int type;
|
||||
char name[MAX_NAME_LENGTH];
|
||||
char defName[MAX_NAME_LENGTH];
|
||||
char groupName[MAX_NAME_LENGTH];
|
||||
char *description;
|
||||
char affiliation[MAX_NAME_LENGTH];
|
||||
int active;
|
||||
int spawned;
|
||||
int id;
|
||||
int side;
|
||||
float x;
|
||||
float y;
|
||||
int offsetX;
|
||||
int offsetY;
|
||||
int w;
|
||||
int h;
|
||||
float dx;
|
||||
float dy;
|
||||
float thrust;
|
||||
float speed;
|
||||
float angle;
|
||||
int alive;
|
||||
int health;
|
||||
int maxHealth;
|
||||
int shield;
|
||||
int maxShield;
|
||||
int reload;
|
||||
int reloadTime;
|
||||
int selectedGunType;
|
||||
int combinedGuns;
|
||||
int shieldRecharge;
|
||||
int shieldRechargeRate;
|
||||
int systemPower;
|
||||
int armourHit;
|
||||
int shieldHit;
|
||||
int systemHit;
|
||||
int thinkTime;
|
||||
int aiActionTime;
|
||||
int aiAggression;
|
||||
int aiDamagePerSec;
|
||||
int aiDamageTimer;
|
||||
int aiEvadeTimer;
|
||||
int separationRadius;
|
||||
int deathType;
|
||||
Weapon guns[MAX_FIGHTER_GUNS];
|
||||
int missiles;
|
||||
long flags;
|
||||
long aiFlags;
|
||||
struct Entity
|
||||
{
|
||||
int type;
|
||||
char name[MAX_NAME_LENGTH];
|
||||
char defName[MAX_NAME_LENGTH];
|
||||
char groupName[MAX_NAME_LENGTH];
|
||||
char *description;
|
||||
char affiliation[MAX_NAME_LENGTH];
|
||||
int active;
|
||||
int spawned;
|
||||
int id;
|
||||
int side;
|
||||
float x;
|
||||
float y;
|
||||
int offsetX;
|
||||
int offsetY;
|
||||
int w;
|
||||
int h;
|
||||
float dx;
|
||||
float dy;
|
||||
float thrust;
|
||||
float speed;
|
||||
float angle;
|
||||
int alive;
|
||||
int health;
|
||||
int maxHealth;
|
||||
int shield;
|
||||
int maxShield;
|
||||
int reload;
|
||||
int reloadTime;
|
||||
int selectedGunType;
|
||||
int combinedGuns;
|
||||
int shieldRecharge;
|
||||
int shieldRechargeRate;
|
||||
int systemPower;
|
||||
int armourHit;
|
||||
int shieldHit;
|
||||
int systemHit;
|
||||
int thinkTime;
|
||||
int aiActionTime;
|
||||
int aiAggression;
|
||||
int aiDamagePerSec;
|
||||
int aiDamageTimer;
|
||||
int aiEvadeTimer;
|
||||
int separationRadius;
|
||||
int deathType;
|
||||
Weapon guns[MAX_FIGHTER_GUNS];
|
||||
int missiles;
|
||||
long flags;
|
||||
long aiFlags;
|
||||
SDL_Point targetLocation;
|
||||
Entity *towing;
|
||||
Entity *target;
|
||||
Entity *leader;
|
||||
Entity *owner;
|
||||
Entity *killedBy;
|
||||
Entity *towing;
|
||||
Entity *target;
|
||||
Entity *leader;
|
||||
Entity *owner;
|
||||
Entity *killedBy;
|
||||
void (*action)(void);
|
||||
void (*draw)(void);
|
||||
void (*die)(void);
|
||||
AtlasImage *texture;
|
||||
Entity *next;
|
||||
Entity *next;
|
||||
};
|
||||
|
||||
struct Bullet {
|
||||
int type;
|
||||
float x;
|
||||
float y;
|
||||
int w;
|
||||
int h;
|
||||
float dx;
|
||||
float dy;
|
||||
int sound;
|
||||
int life;
|
||||
int damage;
|
||||
int angle;
|
||||
long flags;
|
||||
struct Bullet
|
||||
{
|
||||
int type;
|
||||
float x;
|
||||
float y;
|
||||
int w;
|
||||
int h;
|
||||
float dx;
|
||||
float dy;
|
||||
int sound;
|
||||
int life;
|
||||
int damage;
|
||||
int angle;
|
||||
long flags;
|
||||
AtlasImage *texture;
|
||||
Entity *owner;
|
||||
Entity *target;
|
||||
Bullet *next;
|
||||
Entity *owner;
|
||||
Entity *target;
|
||||
Bullet *next;
|
||||
};
|
||||
|
||||
struct Debris {
|
||||
float x;
|
||||
float y;
|
||||
float dx;
|
||||
float dy;
|
||||
int health;
|
||||
int thinkTime;
|
||||
float angle;
|
||||
struct Debris
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float dx;
|
||||
float dy;
|
||||
int health;
|
||||
int thinkTime;
|
||||
float angle;
|
||||
AtlasImage *texture;
|
||||
Debris *next;
|
||||
Debris *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float speed;
|
||||
} Star;
|
||||
|
||||
struct Pulse {
|
||||
int x;
|
||||
int y;
|
||||
float size;
|
||||
int life;
|
||||
int r, g, b;
|
||||
struct Pulse
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
float size;
|
||||
int life;
|
||||
int r, g, b;
|
||||
Pulse *next;
|
||||
};
|
||||
|
||||
struct Effect {
|
||||
int type;
|
||||
float x;
|
||||
float y;
|
||||
float dx;
|
||||
float dy;
|
||||
float health;
|
||||
float size;
|
||||
float scaleAmount;
|
||||
int r;
|
||||
int g;
|
||||
int b;
|
||||
int a;
|
||||
struct Effect
|
||||
{
|
||||
int type;
|
||||
float x;
|
||||
float y;
|
||||
float dx;
|
||||
float dy;
|
||||
float health;
|
||||
float size;
|
||||
float scaleAmount;
|
||||
int r;
|
||||
int g;
|
||||
int b;
|
||||
int a;
|
||||
AtlasImage *texture;
|
||||
Effect *next;
|
||||
Effect *next;
|
||||
};
|
||||
|
||||
struct Location {
|
||||
int active;
|
||||
char name[MAX_NAME_LENGTH];
|
||||
int x;
|
||||
int y;
|
||||
int size;
|
||||
struct Location
|
||||
{
|
||||
int active;
|
||||
char name[MAX_NAME_LENGTH];
|
||||
int x;
|
||||
int y;
|
||||
int size;
|
||||
Location *next;
|
||||
};
|
||||
|
||||
struct Objective {
|
||||
int active;
|
||||
char id[MAX_DESCRIPTION_LENGTH];
|
||||
char description[MAX_DESCRIPTION_LENGTH];
|
||||
char targetName[MAX_NAME_LENGTH];
|
||||
int targetType;
|
||||
int currentValue;
|
||||
int targetValue;
|
||||
int status;
|
||||
int isCondition;
|
||||
int isEliminateAll;
|
||||
int hideNumbers;
|
||||
struct Objective
|
||||
{
|
||||
int active;
|
||||
char id[MAX_DESCRIPTION_LENGTH];
|
||||
char description[MAX_DESCRIPTION_LENGTH];
|
||||
char targetName[MAX_NAME_LENGTH];
|
||||
int targetType;
|
||||
int currentValue;
|
||||
int targetValue;
|
||||
int status;
|
||||
int isCondition;
|
||||
int isEliminateAll;
|
||||
int hideNumbers;
|
||||
Objective *next;
|
||||
};
|
||||
|
||||
struct Challenge {
|
||||
int type;
|
||||
int value;
|
||||
int passed;
|
||||
struct Challenge
|
||||
{
|
||||
int type;
|
||||
int value;
|
||||
int passed;
|
||||
Challenge *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int isChallenge;
|
||||
int timeLimit;
|
||||
int killLimit;
|
||||
int lossLimit;
|
||||
int itemLimit;
|
||||
int playerItemLimit;
|
||||
int escapeLimit;
|
||||
int waypointLimit;
|
||||
int rescueLimit;
|
||||
int disableLimit;
|
||||
int surrenderLimit;
|
||||
int noMissiles;
|
||||
int noBoost;
|
||||
int noECM;
|
||||
int noGuns;
|
||||
int allowPlayerDeath;
|
||||
int clearWaypointEnemies;
|
||||
int eliminateThreats;
|
||||
int isDeathMatch;
|
||||
typedef struct
|
||||
{
|
||||
int isChallenge;
|
||||
int timeLimit;
|
||||
int killLimit;
|
||||
int lossLimit;
|
||||
int itemLimit;
|
||||
int playerItemLimit;
|
||||
int escapeLimit;
|
||||
int waypointLimit;
|
||||
int rescueLimit;
|
||||
int disableLimit;
|
||||
int surrenderLimit;
|
||||
int noMissiles;
|
||||
int noBoost;
|
||||
int noECM;
|
||||
int noGuns;
|
||||
int allowPlayerDeath;
|
||||
int clearWaypointEnemies;
|
||||
int eliminateThreats;
|
||||
int isDeathMatch;
|
||||
Challenge *challenges[MAX_CHALLENGES];
|
||||
} ChallengeData;
|
||||
|
||||
struct Mission {
|
||||
struct Mission
|
||||
{
|
||||
char name[MAX_NAME_LENGTH];
|
||||
char description[MAX_DESCRIPTION_LENGTH];
|
||||
char filename[MAX_DESCRIPTION_LENGTH];
|
||||
int requires;
|
||||
int requiresOptional;
|
||||
int expires;
|
||||
char pilot[MAX_NAME_LENGTH];
|
||||
char squadron[MAX_NAME_LENGTH];
|
||||
char craft[MAX_NAME_LENGTH];
|
||||
int available;
|
||||
int completed;
|
||||
int completedChallenges;
|
||||
int totalChallenges;
|
||||
int epic;
|
||||
int isOptional;
|
||||
int requiresOptional;
|
||||
int expires;
|
||||
char pilot[MAX_NAME_LENGTH];
|
||||
char squadron[MAX_NAME_LENGTH];
|
||||
char craft[MAX_NAME_LENGTH];
|
||||
int available;
|
||||
int completed;
|
||||
int completedChallenges;
|
||||
int totalChallenges;
|
||||
int epic;
|
||||
int isOptional;
|
||||
ChallengeData challengeData;
|
||||
SDL_Rect rect;
|
||||
Mission *next;
|
||||
SDL_Rect rect;
|
||||
Mission *next;
|
||||
};
|
||||
|
||||
struct StarSystem {
|
||||
char name[MAX_NAME_LENGTH];
|
||||
char description[MAX_DESCRIPTION_LENGTH];
|
||||
int side;
|
||||
int x;
|
||||
int y;
|
||||
int completedMissions;
|
||||
int totalMissions;
|
||||
int availableMissions;
|
||||
int fallsToPandorans;
|
||||
int type;
|
||||
Mission *activeMission;
|
||||
Mission missionHead;
|
||||
struct StarSystem
|
||||
{
|
||||
char name[MAX_NAME_LENGTH];
|
||||
char description[MAX_DESCRIPTION_LENGTH];
|
||||
int side;
|
||||
int x;
|
||||
int y;
|
||||
int completedMissions;
|
||||
int totalMissions;
|
||||
int availableMissions;
|
||||
int fallsToPandorans;
|
||||
int type;
|
||||
Mission *activeMission;
|
||||
Mission missionHead;
|
||||
StarSystem *next;
|
||||
};
|
||||
|
||||
struct Quadtree {
|
||||
int depth;
|
||||
int x, y, w, h;
|
||||
Entity **ents;
|
||||
int capacity;
|
||||
int numEnts;
|
||||
int addedTo;
|
||||
struct Quadtree
|
||||
{
|
||||
int depth;
|
||||
int x, y, w, h;
|
||||
Entity **ents;
|
||||
int capacity;
|
||||
int numEnts;
|
||||
int addedTo;
|
||||
Quadtree *node[4];
|
||||
};
|
||||
|
||||
struct Spawner {
|
||||
char name[MAX_NAME_LENGTH];
|
||||
char **types;
|
||||
int numTypes;
|
||||
int side;
|
||||
int time;
|
||||
int interval;
|
||||
int total;
|
||||
int step;
|
||||
int offscreen;
|
||||
int active;
|
||||
char flags[MAX_DESCRIPTION_LENGTH];
|
||||
char aiFlags[MAX_DESCRIPTION_LENGTH];
|
||||
struct Spawner
|
||||
{
|
||||
char name[MAX_NAME_LENGTH];
|
||||
char **types;
|
||||
int numTypes;
|
||||
int side;
|
||||
int time;
|
||||
int interval;
|
||||
int total;
|
||||
int step;
|
||||
int offscreen;
|
||||
int active;
|
||||
char flags[MAX_DESCRIPTION_LENGTH];
|
||||
char aiFlags[MAX_DESCRIPTION_LENGTH];
|
||||
Spawner *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
SDL_Point camera;
|
||||
int numAllies;
|
||||
int numEnemies;
|
||||
int numInitialEnemies;
|
||||
int status;
|
||||
int isEpic;
|
||||
int unlimitedEnemies;
|
||||
int epicFighterLimit;
|
||||
int epicLives;
|
||||
int epicKills;
|
||||
int playerSelect;
|
||||
int manualComplete;
|
||||
int unwinnable;
|
||||
int waypointAutoAdvance;
|
||||
int missionFinishedTimer;
|
||||
int boostTimer;
|
||||
int ecmTimer;
|
||||
int radarRange;
|
||||
int numPlayerGuns;
|
||||
int numObjectivesComplete, numObjectivesTotal, numConditions;
|
||||
int scriptedEnd;
|
||||
int hasThreats;
|
||||
int hasSuspicionLevel;
|
||||
int suspicionLevel;
|
||||
int suspicionCoolOff;
|
||||
int zackariaSuspicionLevel;
|
||||
int incomingMissile;
|
||||
int destroyTorelli;
|
||||
float torelliFireStormAlpha;
|
||||
int campaignFinished;
|
||||
Entity *missionTarget;
|
||||
Entity *jumpgate;
|
||||
Entity *messageSpeaker;
|
||||
Entity *lastKilledPlayer;
|
||||
SDL_Texture *background;
|
||||
AtlasImage *planetTexture, *fireStormTexture;
|
||||
PointF planet;
|
||||
int planetWidth, planetHeight;
|
||||
Entity entityHead, *entityTail;
|
||||
Bullet bulletHead, *bulletTail;
|
||||
Debris debrisHead, *debrisTail;
|
||||
Effect effectHead, *effectTail;
|
||||
Objective objectiveHead, *objectiveTail;
|
||||
Location locationHead, *locationTail;
|
||||
Spawner spawnerHead, *spawnerTail;
|
||||
typedef struct
|
||||
{
|
||||
SDL_Point camera;
|
||||
int numAllies;
|
||||
int numEnemies;
|
||||
int numInitialEnemies;
|
||||
int status;
|
||||
int isEpic;
|
||||
int unlimitedEnemies;
|
||||
int epicFighterLimit;
|
||||
int epicLives;
|
||||
int epicKills;
|
||||
int playerSelect;
|
||||
int manualComplete;
|
||||
int unwinnable;
|
||||
int waypointAutoAdvance;
|
||||
int missionFinishedTimer;
|
||||
int boostTimer;
|
||||
int ecmTimer;
|
||||
int radarRange;
|
||||
int numPlayerGuns;
|
||||
int numObjectivesComplete, numObjectivesTotal, numConditions;
|
||||
int scriptedEnd;
|
||||
int hasThreats;
|
||||
int hasSuspicionLevel;
|
||||
int suspicionLevel;
|
||||
int suspicionCoolOff;
|
||||
int zackariaSuspicionLevel;
|
||||
int incomingMissile;
|
||||
int destroyTorelli;
|
||||
float torelliFireStormAlpha;
|
||||
int campaignFinished;
|
||||
Entity *missionTarget;
|
||||
Entity *jumpgate;
|
||||
Entity *messageSpeaker;
|
||||
Entity *lastKilledPlayer;
|
||||
SDL_Texture *background;
|
||||
AtlasImage *planetTexture, *fireStormTexture;
|
||||
PointF planet;
|
||||
int planetWidth, planetHeight;
|
||||
Entity entityHead, *entityTail;
|
||||
Bullet bulletHead, *bulletTail;
|
||||
Debris debrisHead, *debrisTail;
|
||||
Effect effectHead, *effectTail;
|
||||
Objective objectiveHead, *objectiveTail;
|
||||
Location locationHead, *locationTail;
|
||||
Spawner spawnerHead, *spawnerTail;
|
||||
struct cJSON *missionJSON;
|
||||
unsigned int stats[STAT_MAX];
|
||||
Quadtree quadtree;
|
||||
unsigned int stats[STAT_MAX];
|
||||
Quadtree quadtree;
|
||||
} Battle;
|
||||
|
||||
struct ScriptRunner {
|
||||
struct ScriptRunner
|
||||
{
|
||||
struct cJSON *line;
|
||||
long delay;
|
||||
int waitForMessageBox;
|
||||
long delay;
|
||||
int waitForMessageBox;
|
||||
ScriptRunner *next;
|
||||
};
|
||||
|
||||
struct Trophy {
|
||||
char id[MAX_NAME_LENGTH];
|
||||
char title[MAX_DESCRIPTION_LENGTH];
|
||||
char description[MAX_DESCRIPTION_LENGTH];
|
||||
char awardDateStr[MAX_NAME_LENGTH];
|
||||
int value;
|
||||
int hidden;
|
||||
int stat;
|
||||
int statValue;
|
||||
int awarded;
|
||||
struct Trophy
|
||||
{
|
||||
char id[MAX_NAME_LENGTH];
|
||||
char title[MAX_DESCRIPTION_LENGTH];
|
||||
char description[MAX_DESCRIPTION_LENGTH];
|
||||
char awardDateStr[MAX_NAME_LENGTH];
|
||||
int value;
|
||||
int hidden;
|
||||
int stat;
|
||||
int statValue;
|
||||
int awarded;
|
||||
unsigned long awardDate;
|
||||
int notify;
|
||||
Trophy *next;
|
||||
int notify;
|
||||
Trophy *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int friendlyFire;
|
||||
int autoSwitchPlayerTarget;
|
||||
int missileReTarget;
|
||||
int healthBars;
|
||||
} Gameplay;
|
||||
|
||||
struct Tuple {
|
||||
char key[MAX_NAME_LENGTH];
|
||||
int value;
|
||||
struct Tuple
|
||||
{
|
||||
char key[MAX_NAME_LENGTH];
|
||||
int value;
|
||||
Tuple *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
StarSystem starSystemHead;
|
||||
Mission challengeMissionHead;
|
||||
Mission *currentMission;
|
||||
char selectedStarSystem[MAX_NAME_LENGTH];
|
||||
int completedMissions;
|
||||
int availableMissions;
|
||||
int totalMissions;
|
||||
int completedChallenges;
|
||||
int totalChallenges;
|
||||
typedef struct
|
||||
{
|
||||
StarSystem starSystemHead;
|
||||
Mission challengeMissionHead;
|
||||
Mission *currentMission;
|
||||
char selectedStarSystem[MAX_NAME_LENGTH];
|
||||
int completedMissions;
|
||||
int availableMissions;
|
||||
int totalMissions;
|
||||
int completedChallenges;
|
||||
int totalChallenges;
|
||||
unsigned int stats[STAT_MAX];
|
||||
Trophy trophyHead;
|
||||
Tuple fighterStatHead;
|
||||
Trophy trophyHead;
|
||||
Tuple fighterStatHead;
|
||||
} Game;
|
||||
|
||||
struct Widget {
|
||||
char name[MAX_NAME_LENGTH];
|
||||
char group[MAX_NAME_LENGTH];
|
||||
int type;
|
||||
int value;
|
||||
char text[MAX_NAME_LENGTH];
|
||||
char **options;
|
||||
int numOptions;
|
||||
int visible;
|
||||
int enabled;
|
||||
int isModal;
|
||||
SDL_Rect rect;
|
||||
struct Widget
|
||||
{
|
||||
char name[MAX_NAME_LENGTH];
|
||||
char group[MAX_NAME_LENGTH];
|
||||
int type;
|
||||
int value;
|
||||
char text[MAX_NAME_LENGTH];
|
||||
char **options;
|
||||
int numOptions;
|
||||
int visible;
|
||||
int enabled;
|
||||
int isModal;
|
||||
SDL_Rect rect;
|
||||
AtlasImage *texture;
|
||||
void (*action)(void);
|
||||
void (*onChange)(char *value);
|
||||
|
@ -466,23 +495,26 @@ struct Widget {
|
|||
Widget *next;
|
||||
};
|
||||
|
||||
struct HudMessage {
|
||||
char message[MAX_DESCRIPTION_LENGTH];
|
||||
SDL_Color color;
|
||||
int life;
|
||||
struct HudMessage
|
||||
{
|
||||
char message[MAX_DESCRIPTION_LENGTH];
|
||||
SDL_Color color;
|
||||
int life;
|
||||
HudMessage *next;
|
||||
};
|
||||
|
||||
struct MessageBox {
|
||||
char title[MAX_NAME_LENGTH];
|
||||
char body[MAX_DESCRIPTION_LENGTH];
|
||||
int time;
|
||||
int height;
|
||||
int type;
|
||||
struct MessageBox
|
||||
{
|
||||
char title[MAX_NAME_LENGTH];
|
||||
char body[MAX_DESCRIPTION_LENGTH];
|
||||
int time;
|
||||
int height;
|
||||
int type;
|
||||
MessageBox *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
|
@ -492,37 +524,39 @@ typedef struct {
|
|||
int button[MAX_MOUSE_BUTTONS];
|
||||
} Mouse;
|
||||
|
||||
typedef struct {
|
||||
char saveDir[MAX_FILENAME_LENGTH];
|
||||
int saveGame;
|
||||
int winWidth;
|
||||
int winHeight;
|
||||
SDL_Point uiOffset;
|
||||
int fullscreen;
|
||||
int musicVolume;
|
||||
int soundVolume;
|
||||
int vSync;
|
||||
int doTrophyAlerts;
|
||||
int hideMouse;
|
||||
Gameplay gameplay;
|
||||
Mouse mouse;
|
||||
PointF uiMouse;
|
||||
int keyboard[MAX_KEYBOARD_KEYS];
|
||||
SDL_Texture *backBuffer;
|
||||
SDL_Texture *uiBuffer;
|
||||
typedef struct
|
||||
{
|
||||
char saveDir[MAX_FILENAME_LENGTH];
|
||||
int saveGame;
|
||||
int winWidth;
|
||||
int winHeight;
|
||||
SDL_Point uiOffset;
|
||||
int fullscreen;
|
||||
int musicVolume;
|
||||
int soundVolume;
|
||||
int vSync;
|
||||
int doTrophyAlerts;
|
||||
int hideMouse;
|
||||
Gameplay gameplay;
|
||||
Mouse mouse;
|
||||
PointF uiMouse;
|
||||
int keyboard[MAX_KEYBOARD_KEYS];
|
||||
SDL_Texture *backBuffer;
|
||||
SDL_Texture *uiBuffer;
|
||||
SDL_Renderer *renderer;
|
||||
SDL_Window *window;
|
||||
Delegate delegate;
|
||||
ModalDialog modalDialog;
|
||||
int awaitingWidgetInput;
|
||||
int lastKeyPressed;
|
||||
int lastButtonPressed;
|
||||
int keyControls[CONTROL_MAX];
|
||||
int mouseControls[CONTROL_MAX];
|
||||
int textWidth;
|
||||
SDL_Window *window;
|
||||
Delegate delegate;
|
||||
ModalDialog modalDialog;
|
||||
int awaitingWidgetInput;
|
||||
int lastKeyPressed;
|
||||
int lastButtonPressed;
|
||||
int keyControls[CONTROL_MAX];
|
||||
int mouseControls[CONTROL_MAX];
|
||||
int textWidth;
|
||||
} App;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
SDL_Color red;
|
||||
SDL_Color orange;
|
||||
SDL_Color yellow;
|
||||
|
@ -536,36 +570,42 @@ typedef struct {
|
|||
SDL_Color darkGrey;
|
||||
} Colors;
|
||||
|
||||
struct Credit {
|
||||
char *text;
|
||||
float y;
|
||||
int size;
|
||||
int h;
|
||||
struct Credit
|
||||
{
|
||||
char *text;
|
||||
float y;
|
||||
int size;
|
||||
int h;
|
||||
Credit *next;
|
||||
};
|
||||
|
||||
struct Font {
|
||||
char name[MAX_NAME_LENGTH];
|
||||
struct Font
|
||||
{
|
||||
char name[MAX_NAME_LENGTH];
|
||||
SDL_Texture *texture;
|
||||
SDL_Rect glyphs[MAX_GLYPHS];
|
||||
Font *next;
|
||||
SDL_Rect glyphs[MAX_GLYPHS];
|
||||
Font *next;
|
||||
};
|
||||
|
||||
struct Bucket {
|
||||
char *key, *value;
|
||||
struct Bucket
|
||||
{
|
||||
char *key, *value;
|
||||
Bucket *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
Bucket **bucket;
|
||||
int *bucketCount;
|
||||
int *bucketCount;
|
||||
} HashTable;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int32_t magicNumber, version, stringCount;
|
||||
int32_t originalOffset, translationOffset;
|
||||
} MOHeader;
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int32_t length, offset;
|
||||
} MOEntry;
|
||||
|
|
|
@ -19,15 +19,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "atlas.h"
|
||||
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/textures.h"
|
||||
#include "../system/util.h"
|
||||
#include "atlas.h"
|
||||
|
||||
static void loadAtlasData(void);
|
||||
|
||||
static AtlasImage atlases[NUM_ATLAS_BUCKETS];
|
||||
static AtlasImage atlases[NUM_ATLAS_BUCKETS];
|
||||
static SDL_Texture *atlasTexture;
|
||||
|
||||
void initAtlas(void)
|
||||
|
@ -47,12 +48,12 @@ void setAtlasColor(int r, int g, int b, int a)
|
|||
|
||||
AtlasImage *getAtlasImage(const char *filename)
|
||||
{
|
||||
AtlasImage *a;
|
||||
AtlasImage *a;
|
||||
unsigned long i;
|
||||
|
||||
i = hashcode(filename) % NUM_ATLAS_BUCKETS;
|
||||
|
||||
for (a = atlases[i].next ; a != NULL ; a = a->next)
|
||||
for (a = atlases[i].next; a != NULL; a = a->next)
|
||||
{
|
||||
if (strcmp(a->filename, filename) == 0)
|
||||
{
|
||||
|
@ -69,15 +70,15 @@ AtlasImage *getAtlasImage(const char *filename)
|
|||
char **getAtlasFileList(char *dir, int *count)
|
||||
{
|
||||
AtlasImage *a;
|
||||
int i, bucket;
|
||||
char **filenames;
|
||||
int i, bucket;
|
||||
char **filenames;
|
||||
|
||||
i = 0;
|
||||
filenames = NULL;
|
||||
|
||||
for (bucket = 0 ; bucket < NUM_ATLAS_BUCKETS ; bucket++)
|
||||
for (bucket = 0; bucket < NUM_ATLAS_BUCKETS; bucket++)
|
||||
{
|
||||
for (a = atlases[bucket].next ; a != NULL ; a = a->next)
|
||||
for (a = atlases[bucket].next; a != NULL; a = a->next)
|
||||
{
|
||||
if (strncmp(dir, a->filename, strlen(dir)) == 0)
|
||||
{
|
||||
|
@ -88,14 +89,14 @@ char **getAtlasFileList(char *dir, int *count)
|
|||
|
||||
if (i > 0)
|
||||
{
|
||||
filenames = malloc(sizeof(char*) * i);
|
||||
memset(filenames, 0, sizeof(char*) * i);
|
||||
filenames = malloc(sizeof(char *) * i);
|
||||
memset(filenames, 0, sizeof(char *) * i);
|
||||
|
||||
i = 0;
|
||||
|
||||
for (bucket = 0 ; bucket < NUM_ATLAS_BUCKETS ; bucket++)
|
||||
for (bucket = 0; bucket < NUM_ATLAS_BUCKETS; bucket++)
|
||||
{
|
||||
for (a = atlases[bucket].next ; a != NULL ; a = a->next)
|
||||
for (a = atlases[bucket].next; a != NULL; a = a->next)
|
||||
{
|
||||
if (strncmp(dir, a->filename, strlen(dir)) == 0)
|
||||
{
|
||||
|
@ -113,7 +114,7 @@ char **getAtlasFileList(char *dir, int *count)
|
|||
|
||||
if (filenames)
|
||||
{
|
||||
qsort(filenames, i, sizeof(char*), stringComparator);
|
||||
qsort(filenames, i, sizeof(char *), stringComparator);
|
||||
}
|
||||
|
||||
return filenames;
|
||||
|
@ -121,17 +122,17 @@ char **getAtlasFileList(char *dir, int *count)
|
|||
|
||||
static void loadAtlasData(void)
|
||||
{
|
||||
AtlasImage *atlasImage, *a;
|
||||
int x, y, w, h;
|
||||
cJSON *root, *node;
|
||||
char *text, *filename;
|
||||
AtlasImage *atlasImage, *a;
|
||||
int x, y, w, h;
|
||||
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)
|
||||
for (node = root->child; node != NULL; node = node->next)
|
||||
{
|
||||
filename = cJSON_GetObjectItem(node, "filename")->valuestring;
|
||||
x = cJSON_GetObjectItem(node, "x")->valueint;
|
||||
|
|
|
@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
char **getAtlasFileList(char *dir, int *count);
|
||||
char **getAtlasFileList(char *dir, int *count);
|
||||
AtlasImage *getAtlasImage(const char *filename);
|
||||
void setAtlasColor(int r, int g, int b, int a);
|
||||
void initAtlas(void);
|
||||
void setAtlasColor(int r, int g, int b, int a);
|
||||
void initAtlas(void);
|
||||
|
|
|
@ -19,24 +19,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "controls.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../system/io.h"
|
||||
|
||||
extern App app;
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "controls.h"
|
||||
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
|
||||
static void restoreDefaults(void);
|
||||
|
||||
static const char *controlName[CONTROL_MAX];
|
||||
static Widget *controlWidget[CONTROL_MAX];
|
||||
static char *CONTROLS_TEXT;
|
||||
static char *HELP_TEXT;
|
||||
static char *BACKSPACE_TEXT;
|
||||
static char *ESCAPE_TEXT;
|
||||
static Widget *controlWidget[CONTROL_MAX];
|
||||
static char *CONTROLS_TEXT;
|
||||
static char *HELP_TEXT;
|
||||
static char *BACKSPACE_TEXT;
|
||||
static char *ESCAPE_TEXT;
|
||||
|
||||
void initControls(void)
|
||||
{
|
||||
|
@ -55,11 +56,11 @@ void initControls(void)
|
|||
controlName[CONTROL_PREV_FIGHTER] = _("Previous Fighter");
|
||||
controlName[CONTROL_SCREENSHOT] = _("Screenshot");
|
||||
|
||||
for (i = 0 ; i < CONTROL_MAX ; i++)
|
||||
for (i = 0; i < CONTROL_MAX; i++)
|
||||
{
|
||||
controlWidget[i] = getWidget(getLookupName("CONTROL_", i), "controls");
|
||||
controlWidget[i]->numOptions = 2;
|
||||
controlWidget[i]->options = malloc(2 * sizeof(char*));
|
||||
controlWidget[i]->options = malloc(2 * sizeof(char *));
|
||||
controlWidget[i]->options[0] = malloc(sizeof(char) * MAX_NAME_LENGTH);
|
||||
controlWidget[i]->options[1] = malloc(sizeof(char) * MAX_NAME_LENGTH);
|
||||
strcpy(controlWidget[i]->options[0], "");
|
||||
|
@ -76,7 +77,7 @@ void initControlsDisplay(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < CONTROL_MAX ; i++)
|
||||
for (i = 0; i < CONTROL_MAX; i++)
|
||||
{
|
||||
strcpy(controlWidget[i]->options[0], "");
|
||||
strcpy(controlWidget[i]->options[1], "");
|
||||
|
@ -105,7 +106,7 @@ int isControl(int type)
|
|||
|
||||
int isAcceptControl(void)
|
||||
{
|
||||
return (app.keyboard[SDL_SCANCODE_SPACE] ||app.keyboard[SDL_SCANCODE_RETURN] || isControl(CONTROL_FIRE));
|
||||
return (app.keyboard[SDL_SCANCODE_SPACE] || app.keyboard[SDL_SCANCODE_RETURN] || isControl(CONTROL_FIRE));
|
||||
}
|
||||
|
||||
void clearControl(int type)
|
||||
|
@ -158,7 +159,7 @@ void clearControlConfig(char *name)
|
|||
|
||||
void drawControls(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
SDL_Rect r;
|
||||
|
||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
||||
|
@ -186,7 +187,7 @@ void drawControls(void)
|
|||
r.x += 25;
|
||||
r.y = 125;
|
||||
|
||||
for (i = 0 ; i < CONTROL_MAX ; i++)
|
||||
for (i = 0; i < CONTROL_MAX; i++)
|
||||
{
|
||||
drawText(r.x, r.y + 2, 20, TA_LEFT, colors.white, controlName[i]);
|
||||
|
||||
|
@ -218,11 +219,11 @@ void drawControls(void)
|
|||
|
||||
static void restoreDefaults(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
cJSON *root, *controlsJSON, *node;
|
||||
char *text;
|
||||
char *text;
|
||||
|
||||
text = readFile("data/app/"CONFIG_FILENAME);
|
||||
text = readFile("data/app/" CONFIG_FILENAME);
|
||||
|
||||
root = cJSON_Parse(text);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ void updateControlButton(char *name);
|
|||
void updateControlKey(char *name);
|
||||
void resetAcceptControls(void);
|
||||
void clearControl(int type);
|
||||
int isAcceptControl(void);
|
||||
int isControl(int type);
|
||||
int isAcceptControl(void);
|
||||
int isControl(int type);
|
||||
void initControlsDisplay(void);
|
||||
void initControls(void);
|
||||
|
|
|
@ -19,12 +19,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "dev.h"
|
||||
#include "../galaxy/mission.h"
|
||||
|
||||
extern App app;
|
||||
#include "../galaxy/mission.h"
|
||||
#include "dev.h"
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Dev dev;
|
||||
extern Dev dev;
|
||||
|
||||
void doDevKeys(void)
|
||||
{
|
||||
|
|
|
@ -19,15 +19,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "draw.h"
|
||||
|
||||
#include "../system/input.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/input.h"
|
||||
#include "draw.h"
|
||||
|
||||
extern App app;
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Dev dev;
|
||||
extern Dev dev;
|
||||
|
||||
static void initColor(SDL_Color *c, int r, int g, int b);
|
||||
|
||||
|
@ -162,9 +163,9 @@ void blitRotated(AtlasImage *atlasImage, int x, int y, float angle)
|
|||
|
||||
void drawCircle(int cx, int cy, int radius, int r, int g, int b, int a)
|
||||
{
|
||||
int x = radius;
|
||||
int y = 0;
|
||||
int radiusError = 1 - x;
|
||||
int x = radius;
|
||||
int y = 0;
|
||||
int radiusError = 1 - x;
|
||||
SDL_Point p[8];
|
||||
|
||||
SDL_SetRenderDrawColor(app.renderer, r, g, b, a);
|
||||
|
@ -172,14 +173,22 @@ void drawCircle(int cx, int cy, int radius, int r, int g, int b, int a)
|
|||
|
||||
while (x >= y)
|
||||
{
|
||||
p[0].x = x + cx; p[0].y = y + cy;
|
||||
p[1].x = y + cx; p[1].y = x + cy;
|
||||
p[2].x = -x + cx; p[2].y = y + cy;
|
||||
p[3].x = -y + cx; p[3].y = x + cy;
|
||||
p[4].x = -x + cx; p[4].y = -y + cy;
|
||||
p[5].x = -y + cx; p[5].y = -x + cy;
|
||||
p[6].x = x + cx; p[6].y = -y + cy;
|
||||
p[7].x = y + cx; p[7].y = -x + cy;
|
||||
p[0].x = x + cx;
|
||||
p[0].y = y + cy;
|
||||
p[1].x = y + cx;
|
||||
p[1].y = x + cy;
|
||||
p[2].x = -x + cx;
|
||||
p[2].y = y + cy;
|
||||
p[3].x = -y + cx;
|
||||
p[3].y = x + cy;
|
||||
p[4].x = -x + cx;
|
||||
p[4].y = -y + cy;
|
||||
p[5].x = -y + cx;
|
||||
p[5].y = -x + cy;
|
||||
p[6].x = x + cx;
|
||||
p[6].y = -y + cy;
|
||||
p[7].x = y + cx;
|
||||
p[7].y = -x + cy;
|
||||
SDL_RenderDrawPoints(app.renderer, p, 8);
|
||||
|
||||
y++;
|
||||
|
@ -202,7 +211,7 @@ void scrollBackground(float x, float y)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < 4 ; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
backgroundPoint[i].x += x;
|
||||
backgroundPoint[i].y += y;
|
||||
|
@ -231,10 +240,10 @@ void scrollBackground(float x, float y)
|
|||
|
||||
void drawBackground(SDL_Texture *texture)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
SDL_Rect dstRect;
|
||||
|
||||
for (i = 0 ; i < 4 ; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
dstRect.x = backgroundPoint[i].x;
|
||||
dstRect.y = backgroundPoint[i].y;
|
||||
|
@ -266,8 +275,8 @@ int isOnBattleScreen(int x, int y, int w, int h)
|
|||
|
||||
void saveScreenshot(void)
|
||||
{
|
||||
static int i = 0;
|
||||
char filename[MAX_NAME_LENGTH];
|
||||
static int i = 0;
|
||||
char filename[MAX_NAME_LENGTH];
|
||||
SDL_Surface *sshot;
|
||||
|
||||
sprintf(filename, "/tmp/tbftss/%d.bmp", ++i);
|
||||
|
|
|
@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
void saveScreenshot(void);
|
||||
int isOnBattleScreen(int x, int y, int w, int h);
|
||||
int isOnBattleScreen(int x, int y, int w, int h);
|
||||
void drawBackground(SDL_Texture *texture);
|
||||
void scrollBackground(float x, float y);
|
||||
void drawCircle(int cx, int cy, int radius, int r, int g, int b, int a);
|
||||
|
|
|
@ -18,15 +18,15 @@ Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#include "i18n.h"
|
||||
#include "../system/io.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#define TABLE_SIZE 255
|
||||
#define TABLE_SIZE 255
|
||||
|
||||
static int hashCode(char *);
|
||||
static int hashCode(char *);
|
||||
static void put(char *, char *);
|
||||
static void initTable(void);
|
||||
|
||||
|
@ -34,18 +34,18 @@ static HashTable table;
|
|||
|
||||
void setLanguage(char *applicationName, char *languageCode)
|
||||
{
|
||||
char language[MAX_DESCRIPTION_LENGTH], c[MAX_LINE_LENGTH];
|
||||
char language[MAX_DESCRIPTION_LENGTH], c[MAX_LINE_LENGTH];
|
||||
char **key, **value;
|
||||
#ifndef _WIN32
|
||||
#ifndef _WIN32
|
||||
char *lang;
|
||||
#endif
|
||||
int i, swap;
|
||||
FILE *fp;
|
||||
#endif
|
||||
int i, swap;
|
||||
FILE *fp;
|
||||
MOHeader header;
|
||||
MOEntry *original, *translation;
|
||||
#if DEV == 1
|
||||
int read;
|
||||
#endif
|
||||
#if DEV == 1
|
||||
int read;
|
||||
#endif
|
||||
|
||||
initTable();
|
||||
|
||||
|
@ -53,28 +53,28 @@ void setLanguage(char *applicationName, char *languageCode)
|
|||
|
||||
if (languageCode == NULL)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, c, MAX_LINE_LENGTH);
|
||||
#ifdef _WIN32
|
||||
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, c, MAX_LINE_LENGTH);
|
||||
|
||||
if (c[0] != '\0')
|
||||
{
|
||||
STRNCPY(language, c, MAX_DESCRIPTION_LENGTH);
|
||||
|
||||
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, c, MAX_LINE_LENGTH);
|
||||
|
||||
if (c[0] != '\0')
|
||||
{
|
||||
STRNCPY(language, c, MAX_DESCRIPTION_LENGTH);
|
||||
strncat(language, "_", MAX_DESCRIPTION_LENGTH - strlen(language) - 1);
|
||||
|
||||
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, c, MAX_LINE_LENGTH);
|
||||
|
||||
if (c[0] != '\0')
|
||||
{
|
||||
strncat(language, "_", MAX_DESCRIPTION_LENGTH - strlen(language) - 1);
|
||||
|
||||
strncat(language, c, MAX_DESCRIPTION_LENGTH - strlen(language) - 1);
|
||||
}
|
||||
strncat(language, c, MAX_DESCRIPTION_LENGTH - strlen(language) - 1);
|
||||
}
|
||||
#else
|
||||
if ((lang = getenv("LC_ALL")) || (lang = getenv("LC_CTYPE")) || (lang = getenv("LANG")))
|
||||
{
|
||||
STRNCPY(language, lang, MAX_DESCRIPTION_LENGTH);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
if ((lang = getenv("LC_ALL")) || (lang = getenv("LC_CTYPE")) || (lang = getenv("LANG")))
|
||||
{
|
||||
STRNCPY(language, lang, MAX_DESCRIPTION_LENGTH);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -88,17 +88,17 @@ void setLanguage(char *applicationName, char *languageCode)
|
|||
|
||||
sprintf(c, "%s/%s/LC_MESSAGES/%s.mo", LOCALE_DIR, language, applicationName);
|
||||
|
||||
#if DEV == 1
|
||||
printf("Opening %s\n", c);
|
||||
#endif
|
||||
#if DEV == 1
|
||||
printf("Opening %s\n", c);
|
||||
#endif
|
||||
|
||||
fp = fopen(c, "rb");
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
#if DEV == 1
|
||||
printf("Failed to open %s/%s/LC_MESSAGES/%s.mo\n", LOCALE_DIR, language, applicationName);
|
||||
#endif
|
||||
#if DEV == 1
|
||||
printf("Failed to open %s/%s/LC_MESSAGES/%s.mo\n", LOCALE_DIR, language, applicationName);
|
||||
#endif
|
||||
|
||||
if (strstr(language, "_") == NULL)
|
||||
{
|
||||
|
@ -111,17 +111,17 @@ void setLanguage(char *applicationName, char *languageCode)
|
|||
|
||||
sprintf(c, "%s/%s/LC_MESSAGES/%s.mo", LOCALE_DIR, language, applicationName);
|
||||
|
||||
#if DEV == 1
|
||||
printf("Opening %s\n", c);
|
||||
#endif
|
||||
#if DEV == 1
|
||||
printf("Opening %s\n", c);
|
||||
#endif
|
||||
|
||||
fp = fopen(c, "rb");
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
#if DEV == 1
|
||||
printf("Failed to open %s/%s/LC_MESSAGES/%s.mo\n", LOCALE_DIR, language, applicationName);
|
||||
#endif
|
||||
#if DEV == 1
|
||||
printf("Failed to open %s/%s/LC_MESSAGES/%s.mo\n", LOCALE_DIR, language, applicationName);
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -149,9 +149,9 @@ void setLanguage(char *applicationName, char *languageCode)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
#if DEV == 1
|
||||
printf("MO file has %d entries\n", header.stringCount);
|
||||
#endif
|
||||
#if DEV == 1
|
||||
printf("MO file has %d entries\n", header.stringCount);
|
||||
#endif
|
||||
|
||||
fseek(fp, header.originalOffset, SEEK_SET);
|
||||
|
||||
|
@ -166,7 +166,7 @@ void setLanguage(char *applicationName, char *languageCode)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
for (i=0;i<header.stringCount;i++)
|
||||
for (i = 0; i < header.stringCount; i++)
|
||||
{
|
||||
fread(&original[i].length, sizeof(int32_t), 1, fp);
|
||||
fread(&original[i].offset, sizeof(int32_t), 1, fp);
|
||||
|
@ -189,7 +189,7 @@ void setLanguage(char *applicationName, char *languageCode)
|
|||
|
||||
fseek(fp, header.translationOffset, SEEK_SET);
|
||||
|
||||
for (i=0;i<header.stringCount;i++)
|
||||
for (i = 0; i < header.stringCount; i++)
|
||||
{
|
||||
fread(&translation[i].length, sizeof(int32_t), 1, fp);
|
||||
fread(&translation[i].offset, sizeof(int32_t), 1, fp);
|
||||
|
@ -210,7 +210,7 @@ void setLanguage(char *applicationName, char *languageCode)
|
|||
}
|
||||
}
|
||||
|
||||
for (i=0;i<header.stringCount;i++)
|
||||
for (i = 0; i < header.stringCount; i++)
|
||||
{
|
||||
fseek(fp, original[i].offset, SEEK_SET);
|
||||
|
||||
|
@ -219,7 +219,7 @@ void setLanguage(char *applicationName, char *languageCode)
|
|||
key[i][original[i].length] = '\0';
|
||||
}
|
||||
|
||||
for (i=0;i<header.stringCount;i++)
|
||||
for (i = 0; i < header.stringCount; i++)
|
||||
{
|
||||
fseek(fp, translation[i].offset, SEEK_SET);
|
||||
|
||||
|
@ -230,7 +230,7 @@ void setLanguage(char *applicationName, char *languageCode)
|
|||
|
||||
fclose(fp);
|
||||
|
||||
for (i=0;i<header.stringCount;i++)
|
||||
for (i = 0; i < header.stringCount; i++)
|
||||
{
|
||||
put(key[i], value[i]);
|
||||
|
||||
|
@ -247,31 +247,31 @@ void setLanguage(char *applicationName, char *languageCode)
|
|||
|
||||
free(translation);
|
||||
|
||||
#if DEV == 1
|
||||
read = 0;
|
||||
#if DEV == 1
|
||||
read = 0;
|
||||
|
||||
for (i=0;i<TABLE_SIZE;i++)
|
||||
for (i = 0; i < TABLE_SIZE; i++)
|
||||
{
|
||||
if (table.bucketCount[i] != 0)
|
||||
{
|
||||
if (table.bucketCount[i] != 0)
|
||||
{
|
||||
read++;
|
||||
}
|
||||
read++;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Using %d of %d buckets (%d%%)\n", read, TABLE_SIZE, (read * 100) / TABLE_SIZE);
|
||||
#endif
|
||||
printf("Using %d of %d buckets (%d%%)\n", read, TABLE_SIZE, (read * 100) / TABLE_SIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int hashCode(char *data)
|
||||
{
|
||||
int i, length;
|
||||
int i, length;
|
||||
unsigned int hash;
|
||||
|
||||
length = strlen(data);
|
||||
|
||||
hash = 0;
|
||||
|
||||
for (i=0;i<length;i++)
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
hash = data[i] + (hash << 5) - hash;
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ static void initTable()
|
|||
exit(1);
|
||||
}
|
||||
|
||||
for (i=0;i<TABLE_SIZE;i++)
|
||||
for (i = 0; i < TABLE_SIZE; i++)
|
||||
{
|
||||
table.bucket[i] = malloc(sizeof(Bucket));
|
||||
|
||||
|
@ -306,12 +306,12 @@ static void initTable()
|
|||
|
||||
static void put(char *key, char *value)
|
||||
{
|
||||
Bucket *bucket, *newBucket;
|
||||
Bucket *bucket, *newBucket;
|
||||
unsigned int hash = hashCode(key);
|
||||
|
||||
#if DEV == 1
|
||||
printf("%s = %d\n", key, hash);
|
||||
#endif
|
||||
#if DEV == 1
|
||||
printf("%s = %d\n", key, hash);
|
||||
#endif
|
||||
|
||||
bucket = table.bucket[hash];
|
||||
|
||||
|
@ -329,7 +329,7 @@ static void put(char *key, char *value)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
newBucket->key = malloc(strlen(key) + 1);
|
||||
newBucket->key = malloc(strlen(key) + 1);
|
||||
newBucket->value = malloc(strlen(value) + 1);
|
||||
|
||||
if (newBucket->key == NULL || newBucket->value == NULL)
|
||||
|
@ -351,12 +351,12 @@ static void put(char *key, char *value)
|
|||
|
||||
char *getTranslatedString(char *key)
|
||||
{
|
||||
Bucket *bucket;
|
||||
Bucket *bucket;
|
||||
unsigned int hash = hashCode(key);
|
||||
|
||||
bucket = table.bucket[hash]->next;
|
||||
|
||||
for (;bucket!=NULL;bucket=bucket->next)
|
||||
for (; bucket != NULL; bucket = bucket->next)
|
||||
{
|
||||
if (strcasecmp(key, bucket->key) == 0)
|
||||
{
|
||||
|
@ -369,14 +369,14 @@ char *getTranslatedString(char *key)
|
|||
|
||||
void cleanupLanguage(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Bucket *bucket, *p, *q;
|
||||
|
||||
for (i=0;i<TABLE_SIZE;i++)
|
||||
for (i = 0; i < TABLE_SIZE; i++)
|
||||
{
|
||||
bucket = table.bucket[i];
|
||||
|
||||
for (p=bucket->next;p!=NULL;p=q)
|
||||
for (p = bucket->next; p != NULL; p = q)
|
||||
{
|
||||
free(p->key);
|
||||
free(p->value);
|
||||
|
|
|
@ -17,6 +17,6 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
|
||||
*/
|
||||
|
||||
void cleanupLanguage(void);
|
||||
void cleanupLanguage(void);
|
||||
char *getTranslatedString(char *key);
|
||||
void setLanguage(char *applicationName, char *languageCode);
|
||||
void setLanguage(char *applicationName, char *languageCode);
|
||||
|
|
|
@ -18,43 +18,45 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "init.h"
|
||||
#include <locale.h>
|
||||
#include <SDL2/SDL_image.h>
|
||||
#include "../json/cJSON.h"
|
||||
#include <SDL2/SDL_mixer.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
#include "../game/credits.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../battle/bullets.h"
|
||||
#include "../system/modalDialog.h"
|
||||
#include "../system/io.h"
|
||||
#include "../galaxy/starSystems.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../battle/starfield.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../challenges/challenges.h"
|
||||
#include "../system/controls.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../game/game.h"
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#include "../battle/battle.h"
|
||||
#include "../game/options.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/i18n.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/resources.h"
|
||||
#include "../battle/bullets.h"
|
||||
#include "../battle/capitalShips.h"
|
||||
#include "../system/input.h"
|
||||
#include "../game/stats.h"
|
||||
#include "../galaxy/galacticMap.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../game/fighterDatabase.h"
|
||||
#include "../system/textures.h"
|
||||
#include "../battle/fighters.h"
|
||||
#include "../battle/items.h"
|
||||
#include "../battle/starfield.h"
|
||||
#include "../challenges/challenges.h"
|
||||
#include "../galaxy/galacticMap.h"
|
||||
#include "../galaxy/starSystems.h"
|
||||
#include "../game/credits.h"
|
||||
#include "../game/fighterDatabase.h"
|
||||
#include "../game/game.h"
|
||||
#include "../game/options.h"
|
||||
#include "../game/stats.h"
|
||||
#include "../game/trophies.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../plat/win32/win32Init.h"
|
||||
#include "locale.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/controls.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/i18n.h"
|
||||
#include "../system/input.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/modalDialog.h"
|
||||
#include "../system/resources.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/textures.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "init.h"
|
||||
|
||||
extern App app;
|
||||
|
||||
|
@ -70,7 +72,7 @@ void init18N(int argc, char *argv[])
|
|||
|
||||
setlocale(LC_NUMERIC, "");
|
||||
|
||||
for (i = 1 ; i < argc ; i++)
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "-language") == 0)
|
||||
{
|
||||
|
@ -115,7 +117,7 @@ void initSDL(int argc, char *argv[])
|
|||
windowFlags |= SDL_WINDOW_FULLSCREEN;
|
||||
}
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0)
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0)
|
||||
{
|
||||
printf("Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
|
@ -124,12 +126,12 @@ void initSDL(int argc, char *argv[])
|
|||
SDL_ShowCursor(0);
|
||||
|
||||
if (Mix_OpenAudio(AUDIO_FREQUENCY, MIX_DEFAULT_FORMAT, AUDIO_CHANNELS, AUDIO_CHUNKSIZE) == -1)
|
||||
{
|
||||
{
|
||||
printf("Couldn't initialize SDL Mixer\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
Mix_AllocateChannels(AUDIO_MIX_CHANNELS);
|
||||
Mix_AllocateChannels(AUDIO_MIX_CHANNELS);
|
||||
|
||||
Mix_Volume(-1, app.soundVolume * MIX_MAX_VOLUME / 10);
|
||||
Mix_VolumeMusic(app.musicVolume * MIX_MAX_VOLUME / 10);
|
||||
|
@ -162,35 +164,15 @@ void initSDL(int argc, char *argv[])
|
|||
void initGameSystem(void)
|
||||
{
|
||||
int i, numInitFuns;
|
||||
void (*initFuncs[]) (void) = {
|
||||
initGraphics,
|
||||
initFonts,
|
||||
initResources,
|
||||
initSounds,
|
||||
initWidgets,
|
||||
initGame,
|
||||
loadFighterDefs,
|
||||
loadCapitalShipDefs,
|
||||
loadItemDefs,
|
||||
initBulletDefs,
|
||||
initStarSystems,
|
||||
initChallenges,
|
||||
initStats,
|
||||
initModalDialog,
|
||||
initStars,
|
||||
initControls,
|
||||
initTrophies,
|
||||
initFighterDatabase,
|
||||
updateCustomResolutionOption
|
||||
};
|
||||
void (*initFuncs[])(void) = {initGraphics, initFonts, initResources, initSounds, initWidgets, initGame, loadFighterDefs, loadCapitalShipDefs, loadItemDefs, initBulletDefs, initStarSystems, initChallenges, initStats, initModalDialog, initStars, initControls, initTrophies, initFighterDatabase, updateCustomResolutionOption};
|
||||
|
||||
initAtlas();
|
||||
|
||||
initInput();
|
||||
|
||||
numInitFuns = sizeof(initFuncs) / sizeof(void*);
|
||||
numInitFuns = sizeof(initFuncs) / sizeof(void *);
|
||||
|
||||
for (i = 0 ; i < numInitFuns ; i++)
|
||||
for (i = 0; i < numInitFuns; i++)
|
||||
{
|
||||
showLoadingStep(i + 1, numInitFuns);
|
||||
|
||||
|
@ -234,7 +216,7 @@ static void loadConfig(int argc, char *argv[])
|
|||
char *configFilename;
|
||||
|
||||
/* load default config first */
|
||||
loadConfigFile("data/app/"CONFIG_FILENAME);
|
||||
loadConfigFile("data/app/" CONFIG_FILENAME);
|
||||
|
||||
/* load saved config */
|
||||
configFilename = getSaveFilePath(CONFIG_FILENAME);
|
||||
|
@ -256,9 +238,9 @@ static void loadConfig(int argc, char *argv[])
|
|||
|
||||
static void loadConfigFile(char *filename)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
cJSON *root, *controlsJSON, *node, *gameplayJSON;
|
||||
char *text;
|
||||
char *text;
|
||||
|
||||
text = readFile(filename);
|
||||
|
||||
|
@ -310,8 +292,8 @@ static void loadConfigFile(char *filename)
|
|||
|
||||
void saveConfig(void)
|
||||
{
|
||||
int i;
|
||||
char *out, *configFilename;
|
||||
int i;
|
||||
char *out, *configFilename;
|
||||
cJSON *root, *controlsJSON, *keysJSON, *mouseJSON, *gameplayJSON;
|
||||
|
||||
configFilename = getSaveFilePath(CONFIG_FILENAME);
|
||||
|
@ -327,13 +309,13 @@ void saveConfig(void)
|
|||
cJSON_AddNumberToObject(root, "vSync", app.vSync);
|
||||
|
||||
keysJSON = cJSON_CreateObject();
|
||||
for (i = 0 ; i < CONTROL_MAX ; i++)
|
||||
for (i = 0; i < CONTROL_MAX; i++)
|
||||
{
|
||||
cJSON_AddNumberToObject(keysJSON, getLookupName("CONTROL_", i), app.keyControls[i]);
|
||||
}
|
||||
|
||||
mouseJSON = cJSON_CreateObject();
|
||||
for (i = 0 ; i < CONTROL_MAX ; i++)
|
||||
for (i = 0; i < CONTROL_MAX; i++)
|
||||
{
|
||||
cJSON_AddNumberToObject(mouseJSON, getLookupName("CONTROL_", i), app.mouseControls[i]);
|
||||
}
|
||||
|
@ -365,7 +347,7 @@ static void handleCommandLineConfig(int argc, char *argv[])
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 1 ; i < argc ; i++)
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "-size") == 0)
|
||||
{
|
||||
|
|
|
@ -19,10 +19,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "input.h"
|
||||
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/sound.h"
|
||||
#include "input.h"
|
||||
|
||||
extern App app;
|
||||
|
||||
|
@ -122,7 +123,7 @@ void drawMouse(void)
|
|||
void doInput(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
int x, y;
|
||||
int x, y;
|
||||
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
|
|
|
@ -18,11 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "io.h"
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include "dirent.h"
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#include "../system/util.h"
|
||||
#include "io.h"
|
||||
|
||||
extern App app;
|
||||
|
||||
|
@ -43,7 +45,7 @@ char *getFileLocation(char *filename)
|
|||
return filename;
|
||||
}
|
||||
|
||||
sprintf(path, DATA_DIR"/%s", filename);
|
||||
sprintf(path, DATA_DIR "/%s", filename);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
@ -51,7 +53,7 @@ char *getFileLocation(char *filename)
|
|||
char *readFile(char *filename)
|
||||
{
|
||||
char *buffer = NULL;
|
||||
long length;
|
||||
long length;
|
||||
FILE *file;
|
||||
|
||||
file = fopen(getFileLocation(filename), "rb");
|
||||
|
@ -100,10 +102,10 @@ char *getSaveFilePath(char *filename)
|
|||
|
||||
char **getFileList(char *dir, int *count)
|
||||
{
|
||||
DIR *d;
|
||||
int i;
|
||||
DIR *d;
|
||||
int i;
|
||||
struct dirent *ent;
|
||||
char **filenames;
|
||||
char **filenames;
|
||||
|
||||
i = 0;
|
||||
filenames = NULL;
|
||||
|
@ -120,8 +122,8 @@ char **getFileList(char *dir, int *count)
|
|||
|
||||
if (i > 0)
|
||||
{
|
||||
filenames = malloc(sizeof(char*) * i);
|
||||
memset(filenames, 0, sizeof(char*) * i);
|
||||
filenames = malloc(sizeof(char *) * i);
|
||||
memset(filenames, 0, sizeof(char *) * i);
|
||||
|
||||
rewinddir(d);
|
||||
|
||||
|
@ -147,7 +149,7 @@ char **getFileList(char *dir, int *count)
|
|||
|
||||
if (filenames)
|
||||
{
|
||||
qsort(filenames, i, sizeof(char*), stringComparator);
|
||||
qsort(filenames, i, sizeof(char *), stringComparator);
|
||||
}
|
||||
|
||||
return filenames;
|
||||
|
|
|
@ -19,8 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
char **getFileList(char *dir, int *count);
|
||||
char *getSaveFilePath(char *filename);
|
||||
int writeFile(char *filename, char *data);
|
||||
char *readFile(char *filename);
|
||||
char *getFileLocation(char *filename);
|
||||
int fileExists(char *filename);
|
||||
char *getSaveFilePath(char *filename);
|
||||
int writeFile(char *filename, char *data);
|
||||
char *readFile(char *filename);
|
||||
char *getFileLocation(char *filename);
|
||||
int fileExists(char *filename);
|
||||
|
|
|
@ -18,11 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "lookup.h"
|
||||
#include <SDL2/SDL_image.h>
|
||||
|
||||
static Lookup head;
|
||||
#include "../common.h"
|
||||
|
||||
#include "lookup.h"
|
||||
|
||||
static Lookup head;
|
||||
static Lookup *tail;
|
||||
|
||||
static void addLookup(char *name, long value);
|
||||
|
@ -225,7 +227,7 @@ long lookup(char *name)
|
|||
{
|
||||
Lookup *l;
|
||||
|
||||
for (l = head.next ; l != NULL ; l = l->next)
|
||||
for (l = head.next; l != NULL; l = l->next)
|
||||
{
|
||||
if (strcmp(l->name, name) == 0)
|
||||
{
|
||||
|
@ -244,7 +246,7 @@ char *getLookupName(char *prefix, long num)
|
|||
{
|
||||
Lookup *l;
|
||||
|
||||
for (l = head.next ; l != NULL ; l = l->next)
|
||||
for (l = head.next; l != NULL; l = l->next)
|
||||
{
|
||||
if (l->value == num && strncmp(prefix, l->name, strlen(prefix)) == 0)
|
||||
{
|
||||
|
@ -262,7 +264,7 @@ char *getLookupName(char *prefix, long num)
|
|||
long flagsToLong(char *in, int *add)
|
||||
{
|
||||
char *flag, *flags;
|
||||
long total;
|
||||
long total;
|
||||
|
||||
total = 0;
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void destroyLookups(void);
|
||||
long flagsToLong(char *in, int *add);
|
||||
void destroyLookups(void);
|
||||
long flagsToLong(char *in, int *add);
|
||||
char *getLookupName(char *prefix, long num);
|
||||
long lookup(char *name);
|
||||
void initLookups(void);
|
||||
long lookup(char *name);
|
||||
void initLookups(void);
|
||||
|
|
|
@ -19,19 +19,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "modalDialog.h"
|
||||
|
||||
#include "../system/input.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/widgets.h"
|
||||
#include "../system/input.h"
|
||||
#include "modalDialog.h"
|
||||
|
||||
extern App app;
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
|
||||
static int enableTimer;
|
||||
static int enableTimer;
|
||||
static Widget *ok;
|
||||
static Widget *okCancelOK;
|
||||
static Widget *okCancelCancel;
|
||||
static char textBuffer[MAX_DESCRIPTION_LENGTH];
|
||||
static char textBuffer[MAX_DESCRIPTION_LENGTH];
|
||||
|
||||
void initModalDialog(void)
|
||||
{
|
||||
|
|
|
@ -19,28 +19,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "resources.h"
|
||||
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/io.h"
|
||||
#include "resources.h"
|
||||
|
||||
char **backgrounds;
|
||||
char **planets;
|
||||
char **musicFiles;
|
||||
int numBackgrounds;
|
||||
int numPlanets;
|
||||
int numMusicFiles;
|
||||
int numBackgrounds;
|
||||
int numPlanets;
|
||||
int numMusicFiles;
|
||||
|
||||
void initResources(void)
|
||||
{
|
||||
char **filenames;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
numBackgrounds = numPlanets = numMusicFiles = 0;
|
||||
|
||||
filenames = getFileList("gfx/backgrounds", &numBackgrounds);
|
||||
backgrounds = malloc(sizeof(char*) * numBackgrounds);
|
||||
backgrounds = malloc(sizeof(char *) * numBackgrounds);
|
||||
|
||||
for (i = 0 ; i < numBackgrounds ; i++)
|
||||
for (i = 0; i < numBackgrounds; i++)
|
||||
{
|
||||
backgrounds[i] = malloc(sizeof(char) * MAX_FILENAME_LENGTH);
|
||||
sprintf(backgrounds[i], "gfx/backgrounds/%s", filenames[i]);
|
||||
|
@ -53,9 +54,9 @@ void initResources(void)
|
|||
free(filenames);
|
||||
|
||||
filenames = getAtlasFileList("gfx/planets", &numPlanets);
|
||||
planets = malloc(sizeof(char*) * numPlanets);
|
||||
planets = malloc(sizeof(char *) * numPlanets);
|
||||
|
||||
for (i = 0 ; i < numPlanets ; i++)
|
||||
for (i = 0; i < numPlanets; i++)
|
||||
{
|
||||
planets[i] = malloc(sizeof(char) * MAX_FILENAME_LENGTH);
|
||||
strcpy(planets[i], filenames[i]);
|
||||
|
@ -69,9 +70,9 @@ void initResources(void)
|
|||
|
||||
filenames = getFileList("music/battle/", &numMusicFiles);
|
||||
|
||||
musicFiles = malloc(sizeof(char*) * numMusicFiles);
|
||||
musicFiles = malloc(sizeof(char *) * numMusicFiles);
|
||||
|
||||
for (i = 0 ; i < numMusicFiles ; i++)
|
||||
for (i = 0; i < numMusicFiles; i++)
|
||||
{
|
||||
musicFiles[i] = malloc(sizeof(char) * MAX_FILENAME_LENGTH);
|
||||
sprintf(musicFiles[i], "music/battle/%s", filenames[i]);
|
||||
|
@ -103,17 +104,17 @@ void destroyResources(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < numBackgrounds ; i++)
|
||||
for (i = 0; i < numBackgrounds; i++)
|
||||
{
|
||||
free(backgrounds[i]);
|
||||
}
|
||||
|
||||
for (i = 0 ; i < numPlanets ; i++)
|
||||
for (i = 0; i < numPlanets; i++)
|
||||
{
|
||||
free(planets[i]);
|
||||
}
|
||||
|
||||
for (i = 0 ; i < numMusicFiles ; i++)
|
||||
for (i = 0; i < numMusicFiles; i++)
|
||||
{
|
||||
free(musicFiles[i]);
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void destroyResources(void);
|
||||
void destroyResources(void);
|
||||
char *getMusicFilename(unsigned long i);
|
||||
char *getPlanetTextureName(unsigned long i);
|
||||
char *getBackgroundTextureName(unsigned long i);
|
||||
void initResources(void);
|
||||
void initResources(void);
|
||||
|
|
|
@ -18,14 +18,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "sound.h"
|
||||
#include <SDL2/SDL_mixer.h>
|
||||
#include "../system/util.h"
|
||||
#include "../system/io.h"
|
||||
|
||||
#define MAX_BATTLE_SOUND_DISTANCE 1500
|
||||
#define MIN_BATTLE_SOUND_DISTANCE 100
|
||||
#include "../common.h"
|
||||
|
||||
#include "../system/io.h"
|
||||
#include "../system/util.h"
|
||||
#include "sound.h"
|
||||
|
||||
#define MAX_BATTLE_SOUND_DISTANCE 1500
|
||||
#define MIN_BATTLE_SOUND_DISTANCE 100
|
||||
|
||||
extern Entity *player;
|
||||
|
||||
|
@ -39,7 +41,7 @@ static int lastPlayerY;
|
|||
|
||||
void initSounds(void)
|
||||
{
|
||||
memset(sounds, 0, sizeof(Mix_Chunk*) * SND_MAX);
|
||||
memset(sounds, 0, sizeof(Mix_Chunk *) * SND_MAX);
|
||||
|
||||
music = NULL;
|
||||
|
||||
|
@ -88,7 +90,7 @@ void playSound(int id)
|
|||
void playBattleSound(int id, int x, int y)
|
||||
{
|
||||
float distance, bearing, vol;
|
||||
int channel;
|
||||
int channel;
|
||||
|
||||
if (player->alive == ALIVE_ALIVE || player->alive == ALIVE_ESCAPED)
|
||||
{
|
||||
|
@ -173,7 +175,7 @@ void destroySounds(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < SND_MAX ; i++)
|
||||
for (i = 0; i < SND_MAX; i++)
|
||||
{
|
||||
if (sounds[i])
|
||||
{
|
||||
|
|
|
@ -18,16 +18,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "text.h"
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
#include "../system/textures.h"
|
||||
#include "../system/io.h"
|
||||
|
||||
#define FONT_SIZE 32
|
||||
#define FONT_TEXTURE_SIZE 512
|
||||
#define MAX_WORD_LENGTH 128
|
||||
#define MAX_GLYPH_SIZE 8
|
||||
#include "../common.h"
|
||||
|
||||
#include "../system/io.h"
|
||||
#include "../system/textures.h"
|
||||
#include "text.h"
|
||||
|
||||
#define FONT_SIZE 32
|
||||
#define FONT_TEXTURE_SIZE 512
|
||||
#define MAX_WORD_LENGTH 128
|
||||
#define MAX_GLYPH_SIZE 8
|
||||
|
||||
extern App app;
|
||||
|
||||
|
@ -35,10 +37,10 @@ static void initFont(char *name, char *filename, char *characters);
|
|||
static void drawWord(char *word, int *x, int *y, int startX);
|
||||
static void drawTextLines(int x, int y, int size, int align);
|
||||
static void drawTextLine(int x, int y, int size, int align, const char *line);
|
||||
static int nextGlyph(const char *str, int *i, char *glyphBuffer);
|
||||
static int nextGlyph(const char *str, int *i, char *glyphBuffer);
|
||||
|
||||
static char drawTextBuffer[1024];
|
||||
static Font fontHead;
|
||||
static char drawTextBuffer[1024];
|
||||
static Font fontHead;
|
||||
static Font *fontTail;
|
||||
static Font *activeFont = NULL;
|
||||
static float scale;
|
||||
|
@ -64,13 +66,13 @@ void initFonts(void)
|
|||
static void initFont(char *name, char *filename, char *characters)
|
||||
{
|
||||
SDL_Texture *texture;
|
||||
TTF_Font *font;
|
||||
Font *f;
|
||||
TTF_Font *font;
|
||||
Font *f;
|
||||
SDL_Surface *surface, *text;
|
||||
SDL_Rect dest;
|
||||
int i, n, largest;
|
||||
char glyphBuffer[MAX_GLYPH_SIZE];
|
||||
SDL_Color white = {255, 255, 255, 255};
|
||||
SDL_Rect dest;
|
||||
int i, n, largest;
|
||||
char glyphBuffer[MAX_GLYPH_SIZE];
|
||||
SDL_Color white = {255, 255, 255, 255};
|
||||
|
||||
f = malloc(sizeof(Font));
|
||||
memset(f, 0, sizeof(Font));
|
||||
|
@ -158,7 +160,7 @@ void drawText(int x, int y, int size, int align, SDL_Color color, const char *fo
|
|||
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;
|
||||
int i, n, w, h, currentWidth, len;
|
||||
|
||||
memset(&line, '\0', sizeof(line));
|
||||
memset(&token, '\0', sizeof(token));
|
||||
|
@ -167,7 +169,7 @@ static void drawTextLines(int x, int y, int size, int align)
|
|||
|
||||
n = currentWidth = 0;
|
||||
|
||||
for (i = 0 ; i < len ; i++)
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
token[n++] = drawTextBuffer[i];
|
||||
|
||||
|
@ -201,7 +203,7 @@ static void drawTextLines(int x, int y, int size, int align)
|
|||
|
||||
static void drawTextLine(int x, int y, int size, int align, const char *line)
|
||||
{
|
||||
int i, startX, n, w, h;
|
||||
int i, startX, n, w, h;
|
||||
char word[MAX_WORD_LENGTH];
|
||||
|
||||
scale = size / (FONT_SIZE * 1.0f);
|
||||
|
@ -223,7 +225,7 @@ static void drawTextLine(int x, int y, int size, int align, const char *line)
|
|||
x -= (w / 2);
|
||||
}
|
||||
|
||||
for (i = 0 ; i < strlen(line) ; i++)
|
||||
for (i = 0; i < strlen(line); i++)
|
||||
{
|
||||
word[n++] = line[i];
|
||||
|
||||
|
@ -242,7 +244,7 @@ static void drawTextLine(int x, int y, int size, int align, const char *line)
|
|||
|
||||
static void drawWord(char *word, int *x, int *y, int startX)
|
||||
{
|
||||
int i, n;
|
||||
int i, n;
|
||||
SDL_Rect dest;
|
||||
|
||||
i = 0;
|
||||
|
@ -264,7 +266,7 @@ void useFont(char *name)
|
|||
{
|
||||
Font *f;
|
||||
|
||||
for (f = fontHead.next ; f != NULL ; f = f->next)
|
||||
for (f = fontHead.next; f != NULL; f = f->next)
|
||||
{
|
||||
if (strcmp(f->name, name) == 0)
|
||||
{
|
||||
|
@ -277,7 +279,7 @@ void useFont(char *name)
|
|||
void calcTextDimensions(const char *text, int size, int *w, int *h)
|
||||
{
|
||||
float scale;
|
||||
int i, n;
|
||||
int i, n;
|
||||
|
||||
scale = size / (FONT_SIZE * 1.0f);
|
||||
|
||||
|
@ -296,7 +298,7 @@ void calcTextDimensions(const char *text, int size, int *w, int *h)
|
|||
int getWrappedTextHeight(char *text, int size)
|
||||
{
|
||||
char word[MAX_WORD_LENGTH];
|
||||
int i, y, n, w, h, currentWidth, len;
|
||||
int i, y, n, w, h, currentWidth, len;
|
||||
|
||||
STRNCPY(drawTextBuffer, text, MAX_LINE_LENGTH);
|
||||
|
||||
|
@ -307,7 +309,7 @@ int getWrappedTextHeight(char *text, int size)
|
|||
len = strlen(drawTextBuffer);
|
||||
memset(word, 0, MAX_WORD_LENGTH);
|
||||
|
||||
for (i = 0 ; i < len ; i++)
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
word[n++] = drawTextBuffer[i];
|
||||
|
||||
|
@ -334,11 +336,11 @@ int getWrappedTextHeight(char *text, int size)
|
|||
|
||||
static int nextGlyph(const char *str, int *i, char *glyphBuffer)
|
||||
{
|
||||
int len;
|
||||
unsigned bit;
|
||||
int len;
|
||||
unsigned bit;
|
||||
const char *p;
|
||||
|
||||
bit = (unsigned char) str[*i];
|
||||
bit = (unsigned char)str[*i];
|
||||
|
||||
if (bit < ' ')
|
||||
{
|
||||
|
@ -349,7 +351,7 @@ static int nextGlyph(const char *str, int *i, char *glyphBuffer)
|
|||
|
||||
if (bit >= 0xF0)
|
||||
{
|
||||
bit = (int)(str[*i] & 0x07) << 18;
|
||||
bit = (int)(str[*i] & 0x07) << 18;
|
||||
bit |= (int)(str[*i + 1] & 0x3F) << 12;
|
||||
bit |= (int)(str[*i + 2] & 0x3F) << 6;
|
||||
bit |= (int)(str[*i + 3] & 0x3F);
|
||||
|
@ -358,7 +360,7 @@ static int nextGlyph(const char *str, int *i, char *glyphBuffer)
|
|||
}
|
||||
else if (bit >= 0xE0)
|
||||
{
|
||||
bit = (int)(str[*i] & 0x0F) << 12;
|
||||
bit = (int)(str[*i] & 0x0F) << 12;
|
||||
bit |= (int)(str[*i + 1] & 0x3F) << 6;
|
||||
bit |= (int)(str[*i + 2] & 0x3F);
|
||||
|
||||
|
@ -366,7 +368,7 @@ static int nextGlyph(const char *str, int *i, char *glyphBuffer)
|
|||
}
|
||||
else if (bit >= 0xC0)
|
||||
{
|
||||
bit = (int)(str[*i] & 0x1F) << 6;
|
||||
bit = (int)(str[*i] & 0x1F) << 6;
|
||||
bit |= (int)(str[*i + 1] & 0x3F);
|
||||
|
||||
len = 2;
|
||||
|
|
|
@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
int getWrappedTextHeight(char *text, int size);
|
||||
int getWrappedTextHeight(char *text, int size);
|
||||
void calcTextDimensions(const char *text, int size, int *w, int *h);
|
||||
void useFont(char *name);
|
||||
void drawText(int x, int y, int size, int align, SDL_Color color, const char *format, ...);
|
||||
|
|
|
@ -18,10 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "textures.h"
|
||||
#include <SDL2/SDL_image.h>
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#include "../system/io.h"
|
||||
#include "textures.h"
|
||||
|
||||
extern App app;
|
||||
|
||||
|
@ -32,7 +34,7 @@ static void addTextureToCache(char *name, SDL_Texture *texture);
|
|||
static void addTextureToCache(char *name, SDL_Texture *texture)
|
||||
{
|
||||
Texture *t, *new;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
i = strlen(name) % NUM_TEXTURE_BUCKETS;
|
||||
|
||||
|
@ -75,12 +77,12 @@ static SDL_Texture *loadTexture(char *filename)
|
|||
SDL_Texture *getTexture(char *filename)
|
||||
{
|
||||
Texture *t;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
i = strlen(filename) % NUM_TEXTURE_BUCKETS;
|
||||
|
||||
/* check if the texture is already loaded */
|
||||
for (t = textures[i].next ; t != NULL ; t = t->next)
|
||||
for (t = textures[i].next; t != NULL; t = t->next)
|
||||
{
|
||||
if (strcmp(t->name, filename) == 0)
|
||||
{
|
||||
|
@ -110,9 +112,9 @@ SDL_Texture *toTexture(SDL_Surface *surface, int destroySurface)
|
|||
void destroyTextures(void)
|
||||
{
|
||||
Texture *t, *next;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0 ; i < NUM_TEXTURE_BUCKETS ; i++)
|
||||
for (i = 0; i < NUM_TEXTURE_BUCKETS; i++)
|
||||
{
|
||||
t = textures[i].next;
|
||||
|
||||
|
|
|
@ -18,6 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void destroyTextures(void);
|
||||
void destroyTextures(void);
|
||||
SDL_Texture *toTexture(SDL_Surface *surface, int destroySurface);
|
||||
SDL_Texture *getTexture(char *filename);
|
||||
|
|
|
@ -19,9 +19,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "transition.h"
|
||||
|
||||
#include "../system/draw.h"
|
||||
#include "../system/input.h"
|
||||
#include "transition.h"
|
||||
|
||||
static long transitionStartTime;
|
||||
|
||||
|
|
|
@ -18,10 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "util.h"
|
||||
#include <time.h>
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#include "../json/cJSON.h"
|
||||
#include "util.h"
|
||||
|
||||
float mod(float n, float x)
|
||||
{
|
||||
|
@ -51,17 +53,17 @@ int getDistance(int x1, int y1, int x2, int y2)
|
|||
x = x2 - x1;
|
||||
y = y2 - y1;
|
||||
|
||||
return sqrt(x * x + y *y);
|
||||
return sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
char **toTypeArray(char *types, int *numTypes)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
char **typeArray, *type;
|
||||
|
||||
*numTypes = 1;
|
||||
|
||||
for (i = 0 ; i < strlen(types) ; i++)
|
||||
for (i = 0; i < strlen(types); i++)
|
||||
{
|
||||
if (types[i] == ';')
|
||||
{
|
||||
|
@ -69,7 +71,7 @@ char **toTypeArray(char *types, int *numTypes)
|
|||
}
|
||||
}
|
||||
|
||||
typeArray = malloc(*numTypes * sizeof(char*));
|
||||
typeArray = malloc(*numTypes * sizeof(char *));
|
||||
|
||||
i = 0;
|
||||
type = strtok(types, ";");
|
||||
|
@ -114,7 +116,7 @@ char *timeToDate(long millis)
|
|||
static char DATE[MAX_NAME_LENGTH];
|
||||
|
||||
struct tm *timeinfo;
|
||||
time_t time;
|
||||
time_t time;
|
||||
|
||||
time = millis;
|
||||
|
||||
|
@ -162,7 +164,7 @@ int getJSONValue(cJSON *node, char *name, int defValue)
|
|||
void *resize(void *array, int oldSize, int newSize)
|
||||
{
|
||||
void **newArray;
|
||||
int copySize;
|
||||
int copySize;
|
||||
|
||||
copySize = newSize > oldSize ? oldSize : newSize;
|
||||
|
||||
|
@ -176,16 +178,16 @@ void *resize(void *array, int oldSize, int newSize)
|
|||
|
||||
unsigned long hashcode(const char *str)
|
||||
{
|
||||
unsigned long hash = 5381;
|
||||
int c;
|
||||
unsigned long hash = 5381;
|
||||
int c;
|
||||
|
||||
c = *str;
|
||||
|
||||
while (c)
|
||||
{
|
||||
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
|
||||
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
|
||||
|
||||
c = *str++;
|
||||
c = *str++;
|
||||
}
|
||||
|
||||
hash = ((hash << 5) + hash);
|
||||
|
@ -195,7 +197,7 @@ unsigned long hashcode(const char *str)
|
|||
|
||||
int stringComparator(const void *a, const void *b)
|
||||
{
|
||||
char **s1 = (char **)a;
|
||||
char **s2 = (char **)b;
|
||||
char **s1 = (char **)a;
|
||||
char **s2 = (char **)b;
|
||||
return strcmp(*s1, *s2);
|
||||
}
|
||||
|
|
|
@ -18,16 +18,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
int stringComparator(const void *a, const void *b);
|
||||
int stringComparator(const void *a, const void *b);
|
||||
unsigned long hashcode(const char *str);
|
||||
void *resize(void *array, int oldSize, int newSize);
|
||||
int getJSONValue(struct cJSON *node, char *name, int defValue);
|
||||
char *getJSONValueStr(struct cJSON *node, char *name, char *defValue);
|
||||
char *timeToDate(long millis);
|
||||
char *timeToString(long millis, int showHours);
|
||||
char **toTypeArray(char *types, int *numTypes);
|
||||
int getDistance(int x1, int y1, int x2, int y2);
|
||||
float getAngle(int x1, int y1, int x2, int y2);
|
||||
int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
|
||||
int getPercent(float current, float total);
|
||||
float mod(float n, float x);
|
||||
void *resize(void *array, int oldSize, int newSize);
|
||||
int getJSONValue(struct cJSON *node, char *name, int defValue);
|
||||
char *getJSONValueStr(struct cJSON *node, char *name, char *defValue);
|
||||
char *timeToDate(long millis);
|
||||
char *timeToString(long millis, int showHours);
|
||||
char **toTypeArray(char *types, int *numTypes);
|
||||
int getDistance(int x1, int y1, int x2, int y2);
|
||||
float getAngle(int x1, int y1, int x2, int y2);
|
||||
int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
|
||||
int getPercent(float current, float total);
|
||||
float mod(float n, float x);
|
||||
|
|
|
@ -18,21 +18,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "widgets.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include <SDL2/SDL_image.h>
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/util.h"
|
||||
#include "../system/input.h"
|
||||
#include "../system/controls.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/atlas.h"
|
||||
|
||||
extern App app;
|
||||
#include "../common.h"
|
||||
|
||||
#include "../json/cJSON.h"
|
||||
#include "../system/atlas.h"
|
||||
#include "../system/controls.h"
|
||||
#include "../system/draw.h"
|
||||
#include "../system/input.h"
|
||||
#include "../system/io.h"
|
||||
#include "../system/lookup.h"
|
||||
#include "../system/sound.h"
|
||||
#include "../system/text.h"
|
||||
#include "../system/util.h"
|
||||
#include "widgets.h"
|
||||
|
||||
extern App app;
|
||||
extern Colors colors;
|
||||
|
||||
static void loadWidgets(void);
|
||||
|
@ -45,13 +47,13 @@ static void createSelectButtons(Widget *w);
|
|||
static void handleControlWidgets(void);
|
||||
static void updateSelectWidgets(void);
|
||||
|
||||
static Widget head;
|
||||
static Widget *tail;
|
||||
static Widget *selectedWidget;
|
||||
static Widget *hoverWidget;
|
||||
static Widget head;
|
||||
static Widget *tail;
|
||||
static Widget *selectedWidget;
|
||||
static Widget *hoverWidget;
|
||||
static AtlasImage *optionsLeft;
|
||||
static AtlasImage *optionsRight;
|
||||
static int drawingWidgets;
|
||||
static int drawingWidgets;
|
||||
|
||||
void initWidgets(void)
|
||||
{
|
||||
|
@ -97,7 +99,7 @@ static void updateSelectWidgets(void)
|
|||
{
|
||||
Widget *w;
|
||||
|
||||
for (w = head.next; w != NULL ; w = w->next)
|
||||
for (w = head.next; w != NULL; w = w->next)
|
||||
{
|
||||
if (w->type == WT_SELECT_BUTTON && w->parent)
|
||||
{
|
||||
|
@ -120,7 +122,7 @@ Widget *getWidget(const char *name, const char *group)
|
|||
{
|
||||
Widget *w;
|
||||
|
||||
for (w = head.next; w != NULL ; w = w->next)
|
||||
for (w = head.next; w != NULL; w = w->next)
|
||||
{
|
||||
if (strcmp(w->name, name) == 0 && strcmp(w->group, group) == 0)
|
||||
{
|
||||
|
@ -140,7 +142,7 @@ void selectWidget(const char *name, const char *group)
|
|||
|
||||
void drawWidgets(const char *group)
|
||||
{
|
||||
int mouseOver;
|
||||
int mouseOver;
|
||||
Widget *w;
|
||||
|
||||
drawingWidgets = 1;
|
||||
|
@ -148,7 +150,7 @@ void drawWidgets(const char *group)
|
|||
|
||||
hoverWidget = NULL;
|
||||
|
||||
for (w = head.next; w != NULL ; w = w->next)
|
||||
for (w = head.next; w != NULL; w = w->next)
|
||||
{
|
||||
if ((app.modalDialog.type == MD_NONE || (app.modalDialog.type != MD_NONE && w->isModal)) && w->visible && strcmp(w->group, group) == 0)
|
||||
{
|
||||
|
@ -181,7 +183,7 @@ void drawWidgets(const char *group)
|
|||
setAtlasColor(128, 192, 255, 255);
|
||||
}
|
||||
|
||||
blit(w->texture , w->rect.x, w->rect.y, 0);
|
||||
blit(w->texture, w->rect.x, w->rect.y, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -272,12 +274,12 @@ static void changeSelectedValue(Widget *w, int dir)
|
|||
|
||||
void setWidgetOption(const char *name, const char *group, const char *value)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Widget *w = getWidget(name, group);
|
||||
|
||||
if (w)
|
||||
{
|
||||
for (i = 0 ; i < w->numOptions ; i++)
|
||||
for (i = 0; i < w->numOptions; i++)
|
||||
{
|
||||
if (strcmp(w->options[i], value) == 0)
|
||||
{
|
||||
|
@ -340,7 +342,7 @@ static void handleKeyboard(void)
|
|||
{
|
||||
if (selectedWidget->type == WT_BUTTON)
|
||||
{
|
||||
if (app.keyboard[SDL_SCANCODE_SPACE] ||app.keyboard[SDL_SCANCODE_RETURN])
|
||||
if (app.keyboard[SDL_SCANCODE_SPACE] || app.keyboard[SDL_SCANCODE_RETURN])
|
||||
{
|
||||
playSound(SND_GUI_SELECT);
|
||||
old = selectedWidget;
|
||||
|
@ -398,12 +400,12 @@ static void handleControlWidgets(void)
|
|||
static void loadWidgets()
|
||||
{
|
||||
char **filenames;
|
||||
char path[MAX_FILENAME_LENGTH];
|
||||
int count, i;
|
||||
char path[MAX_FILENAME_LENGTH];
|
||||
int count, i;
|
||||
|
||||
filenames = getFileList("data/widgets", &count);
|
||||
|
||||
for (i = 0 ; i < count ; i++)
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
sprintf(path, "data/widgets/%s", filenames[i]);
|
||||
|
||||
|
@ -417,8 +419,8 @@ static void loadWidgets()
|
|||
|
||||
static void loadWidgetSet(char *filename)
|
||||
{
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
cJSON *root, *node;
|
||||
char *text;
|
||||
Widget *w;
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Loading %s", filename);
|
||||
|
@ -428,7 +430,7 @@ static void loadWidgetSet(char *filename)
|
|||
|
||||
if (root)
|
||||
{
|
||||
for (node = root->child ; node != NULL ; node = node->next)
|
||||
for (node = root->child; node != NULL; node = node->next)
|
||||
{
|
||||
w = malloc(sizeof(Widget));
|
||||
memset(w, 0, sizeof(Widget));
|
||||
|
@ -499,12 +501,12 @@ static void loadWidgetSet(char *filename)
|
|||
|
||||
static void createOptions(Widget *w, char *options)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
char *option;
|
||||
|
||||
w->numOptions = 1;
|
||||
|
||||
for (i = 0 ; i < strlen(options) ; i++)
|
||||
for (i = 0; i < strlen(options); i++)
|
||||
{
|
||||
if (options[i] == ';')
|
||||
{
|
||||
|
@ -512,7 +514,7 @@ static void createOptions(Widget *w, char *options)
|
|||
}
|
||||
}
|
||||
|
||||
w->options = malloc(w->numOptions * sizeof(char*));
|
||||
w->options = malloc(w->numOptions * sizeof(char *));
|
||||
|
||||
i = 0;
|
||||
option = strtok(options, ";");
|
||||
|
@ -531,10 +533,10 @@ static void createOptions(Widget *w, char *options)
|
|||
|
||||
static void createSelectButtons(Widget *w)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Widget *btn;
|
||||
|
||||
for (i = 0 ; i < 2 ; i++)
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
btn = malloc(sizeof(Widget));
|
||||
memcpy(btn, w, sizeof(Widget));
|
||||
|
@ -565,12 +567,12 @@ static void createSelectButtons(Widget *w)
|
|||
|
||||
void autoSizeWidgetButtons(char *group, int recenter)
|
||||
{
|
||||
int width, height, maxWidth;
|
||||
int width, height, maxWidth;
|
||||
Widget *w;
|
||||
|
||||
maxWidth = 0;
|
||||
|
||||
for (w = head.next; w != NULL ; w = w->next)
|
||||
for (w = head.next; w != NULL; w = w->next)
|
||||
{
|
||||
if (strcmp(w->group, group) == 0 && w->type == WT_BUTTON)
|
||||
{
|
||||
|
@ -580,7 +582,7 @@ void autoSizeWidgetButtons(char *group, int recenter)
|
|||
}
|
||||
}
|
||||
|
||||
for (w = head.next; w != NULL ; w = w->next)
|
||||
for (w = head.next; w != NULL; w = w->next)
|
||||
{
|
||||
if (strcmp(w->group, group) == 0 && w->type == WT_BUTTON)
|
||||
{
|
||||
|
@ -596,13 +598,13 @@ void autoSizeWidgetButtons(char *group, int recenter)
|
|||
|
||||
void destroyWidgets(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
Widget *w = head.next;
|
||||
Widget *next;
|
||||
|
||||
while (w)
|
||||
{
|
||||
for (i = 0 ; i < w->numOptions ; i++)
|
||||
for (i = 0; i < w->numOptions; i++)
|
||||
{
|
||||
free(w->options[i]);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
void destroyWidgets(void);
|
||||
void autoSizeWidgetButtons(char *group, int recenter);
|
||||
void setWidgetOption(const char *name, const char *group, const char *value);
|
||||
void drawWidgets(const char *group);
|
||||
void selectWidget(const char *name, const char *group);
|
||||
void destroyWidgets(void);
|
||||
void autoSizeWidgetButtons(char *group, int recenter);
|
||||
void setWidgetOption(const char *name, const char *group, const char *value);
|
||||
void drawWidgets(const char *group);
|
||||
void selectWidget(const char *name, const char *group);
|
||||
Widget *getWidget(const char *name, const char *group);
|
||||
void doWidgets(void);
|
||||
void initWidgets(void);
|
||||
void doWidgets(void);
|
||||
void initWidgets(void);
|
||||
|
|
|
@ -19,10 +19,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "testMission.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "../galaxy/mission.h"
|
||||
|
||||
#include "../battle/battle.h"
|
||||
#include "../galaxy/mission.h"
|
||||
#include "../json/cJSON.h"
|
||||
#include "testMission.h"
|
||||
|
||||
extern Game game;
|
||||
|
||||
|
|
Loading…
Reference in New Issue