Tidy #defines
This commit is contained in:
parent
7e14550cc1
commit
6b89d7e8e7
|
@ -20,11 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define AI_EVADE 0
|
#define AI_EVADE 0
|
||||||
#define AI_FALLBACK 1
|
#define AI_FALLBACK 1
|
||||||
#define AI_HUNT 2
|
#define AI_HUNT 2
|
||||||
#define TURN_SPEED 4
|
#define TURN_SPEED 4
|
||||||
#define TURN_THRESHOLD 2
|
#define TURN_THRESHOLD 2
|
||||||
|
|
||||||
extern void addHudMessage(SDL_Color c, char *format, ...);
|
extern void addHudMessage(SDL_Color c, char *format, ...);
|
||||||
extern void applyFighterBrakes(void);
|
extern void applyFighterBrakes(void);
|
||||||
|
|
|
@ -22,10 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../json/cJSON.h"
|
#include "../json/cJSON.h"
|
||||||
|
|
||||||
#define SHOW_BATTLE 0
|
#define SHOW_BATTLE 0
|
||||||
#define SHOW_MENU 1
|
#define SHOW_MENU 1
|
||||||
#define SHOW_OBJECTIVES 2
|
#define SHOW_OBJECTIVES 2
|
||||||
#define SHOW_OPTIONS 3
|
#define SHOW_OPTIONS 3
|
||||||
|
|
||||||
extern void awardTrophy(char *id);
|
extern void awardTrophy(char *id);
|
||||||
extern void blitScaled(AtlasImage *atlasImage, int x, int y, int w, int h, int center);
|
extern void blitScaled(AtlasImage *atlasImage, int x, int y, int w, int h, int center);
|
||||||
|
|
|
@ -22,10 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../json/cJSON.h"
|
#include "../json/cJSON.h"
|
||||||
|
|
||||||
#define INITIAL_BULLET_DRAW_CAPACITY 32
|
#define INITIAL_BULLET_DRAW_CAPACITY 32
|
||||||
#define MISSILE_LIFE (FPS * 30)
|
#define MISSILE_LIFE (FPS * 30)
|
||||||
#define TURN_SPEED 2
|
#define TURN_SPEED 2
|
||||||
#define TURN_THRESHOLD 3
|
#define TURN_THRESHOLD 3
|
||||||
|
|
||||||
extern void addBulletHitEffect(int x, int y, int r, int g, int b);
|
extern void addBulletHitEffect(int x, int y, int r, int g, int b);
|
||||||
extern void addMissileEngineEffect(Bullet *b);
|
extern void addMissileEngineEffect(Bullet *b);
|
||||||
|
|
|
@ -23,8 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../json/cJSON.h"
|
#include "../json/cJSON.h"
|
||||||
|
|
||||||
#define TURN_SPEED 0.1
|
#define TURN_SPEED 0.1
|
||||||
#define TURN_THRESHOLD 2
|
#define TURN_THRESHOLD 2
|
||||||
|
|
||||||
extern void addDebris(int x, int y, int amount);
|
extern void addDebris(int x, int y, int amount);
|
||||||
extern void addLargeEngineEffect(void);
|
extern void addLargeEngineEffect(void);
|
||||||
|
|
|
@ -22,8 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../json/cJSON.h"
|
#include "../json/cJSON.h"
|
||||||
|
|
||||||
#define INITIAL_DEBRIS_DRAW_CAPACITY 32
|
#define INITIAL_DEBRIS_DRAW_CAPACITY 32
|
||||||
#define MAX_DEBRIS_TEXTURES 6
|
#define MAX_DEBRIS_TEXTURES 6
|
||||||
|
|
||||||
extern void addDebrisFire(int x, int y);
|
extern void addDebrisFire(int x, int y);
|
||||||
extern void blitRotated(AtlasImage *atlasImage, int x, int y, float angle);
|
extern void blitRotated(AtlasImage *atlasImage, int x, int y, float angle);
|
||||||
|
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define INITIAL_EFFECT_DRAW_CAPACITY 128
|
#define INITIAL_EFFECT_DRAW_CAPACITY 128
|
||||||
|
|
||||||
extern void blitScaled(AtlasImage *atlasImage, int x, int y, int w, int h, int center);
|
extern void blitScaled(AtlasImage *atlasImage, int x, int y, int w, int h, int center);
|
||||||
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
|
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
|
||||||
|
|
|
@ -20,9 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define DISABLED_GLOW_MAX 255
|
#define DISABLED_GLOW_MAX 255
|
||||||
#define DISABLED_GLOW_MIN 128
|
#define DISABLED_GLOW_MIN 128
|
||||||
#define DISABLED_GLOW_SPEED 3
|
#define DISABLED_GLOW_SPEED 3
|
||||||
|
|
||||||
extern void addToQuadtree(Entity *e, Quadtree *root);
|
extern void addToQuadtree(Entity *e, Quadtree *root);
|
||||||
extern void awardTrophy(char *id);
|
extern void awardTrophy(char *id);
|
||||||
|
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define MAX_HUD_MESSAGES 6
|
#define MAX_HUD_MESSAGES 6
|
||||||
|
|
||||||
extern void blit(AtlasImage *atlasImage, int x, int y, int center);
|
extern void blit(AtlasImage *atlasImage, int x, int y, int center);
|
||||||
extern void blitRotated(AtlasImage *atlasImage, int x, int y, float angle);
|
extern void blitRotated(AtlasImage *atlasImage, int x, int y, float angle);
|
||||||
|
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define ESCAPE_DISTANCE 256
|
#define ESCAPE_DISTANCE 256
|
||||||
|
|
||||||
extern void addDebris(int x, int y, int amount);
|
extern void addDebris(int x, int y, int amount);
|
||||||
extern void addSmallExplosion(void);
|
extern void addSmallExplosion(void);
|
||||||
|
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define MSG_BOX_TEXT_WIDTH 600
|
#define MSG_BOX_TEXT_WIDTH 600
|
||||||
|
|
||||||
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||||
extern int getWrappedTextHeight(char *text, int size);
|
extern int getWrappedTextHeight(char *text, int size);
|
||||||
|
|
|
@ -20,9 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define DAMAGE_RANGE 250
|
#define DAMAGE_RANGE 250
|
||||||
#define SYSTEM_POWER 50
|
#define SYSTEM_POWER 50
|
||||||
#define TRIGGER_RANGE 150
|
#define TRIGGER_RANGE 150
|
||||||
|
|
||||||
extern void addMineExplosion(void);
|
extern void addMineExplosion(void);
|
||||||
extern void awardTrophy(char *id);
|
extern void awardTrophy(char *id);
|
||||||
|
|
|
@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../json/cJSON.h"
|
#include "../json/cJSON.h"
|
||||||
|
|
||||||
#define MAX_SELECTABLE_PLAYERS 8
|
#define MAX_SELECTABLE_PLAYERS 8
|
||||||
#define MAX_SELECTABLE_TARGETS 8
|
#define MAX_SELECTABLE_TARGETS 8
|
||||||
|
|
||||||
extern void addECMEffect(Entity *ent);
|
extern void addECMEffect(Entity *ent);
|
||||||
extern void addHudMessage(SDL_Color c, char *format, ...);
|
extern void addHudMessage(SDL_Color c, char *format, ...);
|
||||||
|
|
|
@ -20,8 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define QT_INITIAL_CAPACITY 8
|
#define QT_INITIAL_CAPACITY 8
|
||||||
#define QT_MAX_DEPTH 5
|
#define QT_MAX_DEPTH 5
|
||||||
|
|
||||||
extern void *resize(void *array, int oldSize, int newSize);
|
extern void *resize(void *array, int oldSize, int newSize);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define ROPE_DISTANCE 128
|
#define ROPE_DISTANCE 128
|
||||||
|
|
||||||
extern void addHudMessage(SDL_Color c, char *format, ...);
|
extern void addHudMessage(SDL_Color c, char *format, ...);
|
||||||
extern Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore);
|
extern Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore);
|
||||||
|
|
|
@ -20,13 +20,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define CHALLENGES_PER_PAGE 14
|
#define CHALLENGES_PER_PAGE 14
|
||||||
#define SHOW_CHALLENGES 0
|
#define SHOW_CHALLENGES 0
|
||||||
#define SHOW_FIGHTER_DB 5
|
#define SHOW_FIGHTER_DB 5
|
||||||
#define SHOW_MENU 1
|
#define SHOW_MENU 1
|
||||||
#define SHOW_OPTIONS 2
|
#define SHOW_OPTIONS 2
|
||||||
#define SHOW_STATS 3
|
#define SHOW_STATS 3
|
||||||
#define SHOW_TROPHIES 4
|
#define SHOW_TROPHIES 4
|
||||||
|
|
||||||
extern void autoSizeWidgetButtons(char *group, int recenter);
|
extern void autoSizeWidgetButtons(char *group, int recenter);
|
||||||
extern void awardChallengeTrophies(void);
|
extern void awardChallengeTrophies(void);
|
||||||
|
|
|
@ -20,14 +20,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define MAX_LISTED_MISSIONS 9
|
#define MAX_LISTED_MISSIONS 9
|
||||||
#define SHOW_FIGHTER_DB 6
|
#define SHOW_FIGHTER_DB 6
|
||||||
#define SHOW_GALAXY 0
|
#define SHOW_GALAXY 0
|
||||||
#define SHOW_MENU 2
|
#define SHOW_MENU 2
|
||||||
#define SHOW_OPTIONS 3
|
#define SHOW_OPTIONS 3
|
||||||
#define SHOW_STAR_SYSTEM 1
|
#define SHOW_STAR_SYSTEM 1
|
||||||
#define SHOW_STATS 4
|
#define SHOW_STATS 4
|
||||||
#define SHOW_TROPHIES 5
|
#define SHOW_TROPHIES 5
|
||||||
|
|
||||||
extern void autoSizeWidgetButtons(char *group, int recenter);
|
extern void autoSizeWidgetButtons(char *group, int recenter);
|
||||||
extern void awardCampaignTrophies(void);
|
extern void awardCampaignTrophies(void);
|
||||||
|
|
|
@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../json/cJSON.h"
|
#include "../json/cJSON.h"
|
||||||
|
|
||||||
#define CREDIT_LINE_LIMIT (UI_WIDTH - 300)
|
#define CREDIT_LINE_LIMIT (UI_WIDTH - 300)
|
||||||
|
|
||||||
extern void blit(AtlasImage *atlasImage, int x, int y, int centered);
|
extern void blit(AtlasImage *atlasImage, int x, int y, int centered);
|
||||||
extern void drawBackground(SDL_Texture *texture);
|
extern void drawBackground(SDL_Texture *texture);
|
||||||
|
|
|
@ -22,8 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "SDL2/SDL_mixer.h"
|
#include "SDL2/SDL_mixer.h"
|
||||||
|
|
||||||
#define SHOW_CONTROLS 1
|
#define SHOW_CONTROLS 1
|
||||||
#define SHOW_MAIN 0
|
#define SHOW_MAIN 0
|
||||||
|
|
||||||
extern void drawControls(void);
|
extern void drawControls(void);
|
||||||
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||||
|
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define STATS_PER_PAGE 9
|
#define STATS_PER_PAGE 9
|
||||||
|
|
||||||
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||||
extern void drawWidgets(char *groupName);
|
extern void drawWidgets(char *groupName);
|
||||||
|
|
|
@ -20,12 +20,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define NUM_FIGHTERS 12
|
#define NUM_FIGHTERS 12
|
||||||
#define SHOW_FIGHTER_DB 4
|
#define SHOW_FIGHTER_DB 4
|
||||||
#define SHOW_OPTIONS 2
|
#define SHOW_OPTIONS 2
|
||||||
#define SHOW_STATS 1
|
#define SHOW_STATS 1
|
||||||
#define SHOW_TITLE 0
|
#define SHOW_TITLE 0
|
||||||
#define SHOW_TROPHIES 3
|
#define SHOW_TROPHIES 3
|
||||||
|
|
||||||
extern void addEngineEffect(void);
|
extern void addEngineEffect(void);
|
||||||
extern void autoSizeWidgetButtons(char *group, int recenter);
|
extern void autoSizeWidgetButtons(char *group, int recenter);
|
||||||
|
|
|
@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
|
||||||
#define TROPHIES_PER_PAGE 4
|
#define TROPHIES_PER_PAGE 4
|
||||||
|
|
||||||
extern void awardPandoranCraftTrophy(void);
|
extern void awardPandoranCraftTrophy(void);
|
||||||
extern void blit(AtlasImage *atlasImage, int x, int y, int centered);
|
extern void blit(AtlasImage *atlasImage, int x, int y, int centered);
|
||||||
|
|
|
@ -22,8 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "SDL2/SDL_mixer.h"
|
#include "SDL2/SDL_mixer.h"
|
||||||
|
|
||||||
#define MAX_BATTLE_SOUND_DISTANCE 1500
|
#define MAX_BATTLE_SOUND_DISTANCE 1500
|
||||||
#define MIN_BATTLE_SOUND_DISTANCE 100
|
#define MIN_BATTLE_SOUND_DISTANCE 100
|
||||||
|
|
||||||
extern float getAngle(int x1, int y1, int x2, int y2);
|
extern float getAngle(int x1, int y1, int x2, int y2);
|
||||||
extern int getDistance(int x1, int y1, int x2, int y2);
|
extern int getDistance(int x1, int y1, int x2, int y2);
|
||||||
|
|
|
@ -26,9 +26,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
|
||||||
#define FONT_SIZE 32
|
#define FONT_SIZE 32
|
||||||
#define FONT_TEXTURE_SIZE 512
|
#define FONT_TEXTURE_SIZE 512
|
||||||
#define MAX_WORD_LENGTH 128
|
#define MAX_WORD_LENGTH 128
|
||||||
|
|
||||||
extern char *getFileLocation(char *filename);
|
extern char *getFileLocation(char *filename);
|
||||||
extern unsigned long hashcode(const char *str);
|
extern unsigned long hashcode(const char *str);
|
||||||
|
|
|
@ -33,9 +33,9 @@ extern char **getFileList(char *dir, int *count);
|
||||||
extern long lookup(char *name);
|
extern long lookup(char *name);
|
||||||
extern void playSound(int id);
|
extern void playSound(int id);
|
||||||
extern char *readFile(char *filename);
|
extern char *readFile(char *filename);
|
||||||
|
extern void setAtlasColor(int r, int g, int b, int a);
|
||||||
extern void updateControlButton(char *name);
|
extern void updateControlButton(char *name);
|
||||||
extern void updateControlKey(char *name);
|
extern void updateControlKey(char *name);
|
||||||
extern void setAtlasColor(int r, int g, int b, int a);
|
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
|
|
@ -28,10 +28,10 @@ function funcSort($a, $b)
|
||||||
{
|
{
|
||||||
$a = str_replace("*", "", $a);
|
$a = str_replace("*", "", $a);
|
||||||
$b = str_replace("*", "", $b);
|
$b = str_replace("*", "", $b);
|
||||||
|
|
||||||
$aParts = explode(" ", $a);
|
$aParts = explode(" ", $a);
|
||||||
$bParts = explode(" ", $b);
|
$bParts = explode(" ", $b);
|
||||||
|
|
||||||
return strcmp($aParts[2], $bParts[2]);
|
return strcmp($aParts[2], $bParts[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ function updateExterns($header, $defines, $functions, $structs)
|
||||||
asort($defines);
|
asort($defines);
|
||||||
usort($functions, "funcSort");
|
usort($functions, "funcSort");
|
||||||
asort($structs);
|
asort($structs);
|
||||||
|
|
||||||
$newHeader = [];
|
$newHeader = [];
|
||||||
|
|
||||||
foreach ($header as $line)
|
foreach ($header as $line)
|
||||||
{
|
{
|
||||||
$newHeader[] = $line;
|
$newHeader[] = $line;
|
||||||
|
@ -53,7 +53,7 @@ function updateExterns($header, $defines, $functions, $structs)
|
||||||
$newHeader[] = "\n";
|
$newHeader[] = "\n";
|
||||||
$newHeader = array_merge($newHeader, $defines);
|
$newHeader = array_merge($newHeader, $defines);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($functions) > 0)
|
if (count($functions) > 0)
|
||||||
{
|
{
|
||||||
$newHeader[] = "\n";
|
$newHeader[] = "\n";
|
||||||
|
@ -79,32 +79,32 @@ function cleanHeader($headerFile)
|
||||||
|
|
||||||
$bodyFile = $headerFile;
|
$bodyFile = $headerFile;
|
||||||
$bodyFile[strlen($bodyFile) - 1] = 'c';
|
$bodyFile[strlen($bodyFile) - 1] = 'c';
|
||||||
|
|
||||||
if (file_exists($bodyFile))
|
if (file_exists($bodyFile))
|
||||||
{
|
{
|
||||||
$header = file($headerFile);
|
$header = file($headerFile);
|
||||||
$body = file_get_contents($bodyFile);
|
$body = file_get_contents($bodyFile);
|
||||||
$isMain = strpos($body, "int main(int argc, char *argv[])");
|
$isMain = strpos($body, "int main(");
|
||||||
$lines = [];
|
$lines = [];
|
||||||
$defines = [];
|
$defines = [];
|
||||||
$functions = [];
|
$functions = [];
|
||||||
$structs = [];
|
$structs = [];
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$hasChanges = false;
|
$hasChanges = false;
|
||||||
|
|
||||||
foreach ($header as $line)
|
foreach ($header as $line)
|
||||||
{
|
{
|
||||||
if ((preg_match("/extern|define/", $line) || preg_match("/;$/", $line)))
|
if ((preg_match("/extern|define/", $line) || preg_match("/;$/", $line)))
|
||||||
{
|
{
|
||||||
preg_match($func_pattern, $line, $matches);
|
preg_match($func_pattern, $line, $matches);
|
||||||
|
|
||||||
if (count($matches) == 3)
|
if (count($matches) == 3)
|
||||||
{
|
{
|
||||||
unset($header[$i]);
|
unset($header[$i]);
|
||||||
|
|
||||||
$extern = $matches[2];
|
$extern = $matches[2];
|
||||||
|
|
||||||
if (!preg_match_all("/\b${extern}\b/", $body))
|
if (!preg_match_all("/\b${extern}\b/", $body))
|
||||||
{
|
{
|
||||||
if (!$hasChanges)
|
if (!$hasChanges)
|
||||||
|
@ -119,17 +119,17 @@ function cleanHeader($headerFile)
|
||||||
$functions[] = $line;
|
$functions[] = $line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preg_match($struct_pattern, $line, $matches);
|
preg_match($struct_pattern, $line, $matches);
|
||||||
|
|
||||||
if (count($matches) == 2)
|
if (count($matches) == 2)
|
||||||
{
|
{
|
||||||
unset($header[$i]);
|
unset($header[$i]);
|
||||||
|
|
||||||
$extern = $matches[1];
|
$extern = $matches[1];
|
||||||
|
|
||||||
$externs[] = $extern;
|
$externs[] = $extern;
|
||||||
|
|
||||||
if (!$isMain)
|
if (!$isMain)
|
||||||
{
|
{
|
||||||
if (!preg_match_all("/\b${extern}\b/", $body))
|
if (!preg_match_all("/\b${extern}\b/", $body))
|
||||||
|
@ -151,17 +151,17 @@ function cleanHeader($headerFile)
|
||||||
$structs[] = $line;
|
$structs[] = $line;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preg_match($define_pattern, $line, $matches);
|
preg_match($define_pattern, $line, $matches);
|
||||||
|
|
||||||
if (count($matches) == 2)
|
if (count($matches) == 2)
|
||||||
{
|
{
|
||||||
unset($header[$i]);
|
unset($header[$i]);
|
||||||
|
|
||||||
$extern = $matches[1];
|
$extern = $matches[1];
|
||||||
|
|
||||||
$externs[] = $extern;
|
$externs[] = $extern;
|
||||||
|
|
||||||
if (strstr($body, "$extern") === FALSE)
|
if (strstr($body, "$extern") === FALSE)
|
||||||
{
|
{
|
||||||
if (!$hasChanges)
|
if (!$hasChanges)
|
||||||
|
@ -177,7 +177,7 @@ function cleanHeader($headerFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,13 +192,15 @@ function cleanHeader($headerFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ($wasBlank);
|
while ($wasBlank);
|
||||||
|
|
||||||
$defines = array_unique($defines);
|
$defines = array_unique($defines);
|
||||||
$functions = array_unique($functions);
|
$functions = array_unique($functions);
|
||||||
$structs = array_unique($structs);
|
$structs = array_unique($structs);
|
||||||
|
|
||||||
|
$defines = alignDefines($defines);
|
||||||
|
|
||||||
$header = updateExterns($header, $defines, $functions, $structs);
|
$header = updateExterns($header, $defines, $functions, $structs);
|
||||||
|
|
||||||
if ($UPDATE_FILES)
|
if ($UPDATE_FILES)
|
||||||
{
|
{
|
||||||
file_put_contents($headerFile, $header);
|
file_put_contents($headerFile, $header);
|
||||||
|
@ -206,12 +208,36 @@ function cleanHeader($headerFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function alignDefines($defines)
|
||||||
|
{
|
||||||
|
$newAligns = [];
|
||||||
|
$largest = 0;
|
||||||
|
$defineName;
|
||||||
|
$defineValue;
|
||||||
|
|
||||||
|
foreach ($defines as $define)
|
||||||
|
{
|
||||||
|
sscanf($define, "%*s %s", $defineName);
|
||||||
|
|
||||||
|
$largest = max($largest, strlen($defineName) + 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($defines as $define)
|
||||||
|
{
|
||||||
|
sscanf($define, "%*s %s %[^\n]", $defineName, $defineValue);
|
||||||
|
|
||||||
|
$newAligns[] = "#define " . str_pad($defineName, $largest, " ") . $defineValue . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $newAligns;
|
||||||
|
}
|
||||||
|
|
||||||
function recurseDir($dir)
|
function recurseDir($dir)
|
||||||
{
|
{
|
||||||
if ($dir != "../src/json")
|
if ($dir != "../src/json")
|
||||||
{
|
{
|
||||||
$files = array_diff(scandir($dir), array('..', '.'));
|
$files = array_diff(scandir($dir), array('..', '.'));
|
||||||
|
|
||||||
foreach ($files as $file)
|
foreach ($files as $file)
|
||||||
{
|
{
|
||||||
if (is_dir("$dir/$file"))
|
if (is_dir("$dir/$file"))
|
||||||
|
|
Loading…
Reference in New Issue