Code/comments cleanups. Renamed main_loop to MainLoopJmpBuf and moved extern to user files.
This commit is contained in:
parent
26c40af93c
commit
580d8b1446
4 changed files with 90 additions and 22 deletions
src
|
@ -470,11 +470,6 @@ extern unsigned SyncRandSeed; /// Sync random seed value
|
|||
|
||||
extern unsigned long GameCycle; /// Game simulation cycle counter
|
||||
|
||||
#if DEBUG
|
||||
#include <setjmp.h>
|
||||
extern jmp_buf main_loop;
|
||||
#endif
|
||||
|
||||
extern void LoadGame(char*); /// Load saved game back
|
||||
extern void SaveGame(const char*); /// Save game for later load
|
||||
|
||||
|
|
|
@ -1,5 +1,30 @@
|
|||
// ___________ _________ _____ __
|
||||
// \_ _____/______ ____ ____ \_ ___ \____________ _/ ____\/ |_
|
||||
// | __) \_ __ \_/ __ \_/ __ \/ \ \/\_ __ \__ \\ __\\ __\
|
||||
// | \ | | \/\ ___/\ ___/\ \____| | \// __ \| | | |
|
||||
// \___ / |__| \___ >\___ >\______ /|__| (____ /__| |__|
|
||||
// \/ \/ \/ \/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// FreeCraft - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name pf_lowlevel.c - Pathfinder low level functions. */
|
||||
//
|
||||
// (c) Copyright 2002 by Latimerius
|
||||
//
|
||||
// FreeCraft is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the License,
|
||||
// or (at your option) any later version.
|
||||
//
|
||||
// FreeCraft is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
/* $Id$ */
|
||||
//@{
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -7,6 +32,9 @@
|
|||
#include <limits.h>
|
||||
|
||||
#include "freecraft.h"
|
||||
|
||||
#ifdef HIERARCHIC_PATHFINDER // {
|
||||
|
||||
#include "unit.h"
|
||||
#include "map.h"
|
||||
#if defined(DEBUG) && defined(TIMEIT)
|
||||
|
@ -18,7 +46,10 @@
|
|||
#include "pf_lowlevel.h"
|
||||
#include "pf_low_open.h"
|
||||
|
||||
#ifdef HIERARCHIC_PATHFINDER // {
|
||||
#ifdef DEBUG
|
||||
#include <setjmp.h>
|
||||
extern jmp_buf MainLoopJmpBuf;
|
||||
#endif
|
||||
|
||||
#define COST_MOVING_UNIT 2
|
||||
#define COST_WAITING_UNIT 4
|
||||
|
@ -369,7 +400,7 @@ local MapField *LowAstarLoop (Unit *unit)
|
|||
#endif
|
||||
if (obstacle->Moving) {
|
||||
NeighCost = SCALE * COST_MOVING_UNIT;
|
||||
} else if ((obstacle->Wait &&
|
||||
} else if ((obstacle->Wait &&
|
||||
obstacle->Orders[0].Action == UnitActionMove)) {
|
||||
NeighCost = SCALE * COST_WAITING_UNIT;
|
||||
} else
|
||||
|
@ -466,7 +497,7 @@ local int LowTraceback (Unit *unit, MapField *end)
|
|||
//printf ("(%d,%d) ", x, y);
|
||||
x += Neighbor[(int )mf->Traceback].dx;
|
||||
y += Neighbor[(int )mf->Traceback].dy;
|
||||
|
||||
|
||||
++path_length;
|
||||
if (prev_traceback >= 0) {
|
||||
//printf ("path[%d] = %d", path_ptr,
|
||||
|
@ -707,3 +738,5 @@ void ExportMap (void)
|
|||
#endif
|
||||
|
||||
#endif // } HIERARCHIC_PATHFINDER
|
||||
|
||||
//@}
|
||||
|
|
|
@ -1,10 +1,39 @@
|
|||
|
||||
/* $Id$ */
|
||||
// ___________ _________ _____ __
|
||||
// \_ _____/______ ____ ____ \_ ___ \____________ _/ ____\/ |_
|
||||
// | __) \_ __ \_/ __ \_/ __ \/ \ \/\_ __ \__ \\ __\\ __\
|
||||
// | \ | | \/\ ___/\ ___/\ \____| | \// __ \| | | |
|
||||
// \___ / |__| \___ >\___ >\______ /|__| (____ /__| |__|
|
||||
// \/ \/ \/ \/ \/
|
||||
// ______________________ ______________________
|
||||
// T H E W A R B E G I N S
|
||||
// FreeCraft - A free fantasy real time strategy game engine
|
||||
//
|
||||
/**@name region_groups.c - Pathfinder region groups functions. */
|
||||
//
|
||||
// (c) Copyright 2002 by Latimerius
|
||||
//
|
||||
// FreeCraft is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the License,
|
||||
// or (at your option) any later version.
|
||||
//
|
||||
// FreeCraft is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// $Id$
|
||||
|
||||
//@{
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "freecraft.h"
|
||||
|
||||
#ifdef HIERARCHIC_PATHFINDER // {
|
||||
|
||||
#include "map.h"
|
||||
#include "unit.h"
|
||||
#if defined(DEBUG) && defined(TIMEIT)
|
||||
|
@ -15,7 +44,11 @@
|
|||
#include "region_set.h"
|
||||
#include "region_groups.h"
|
||||
|
||||
#ifdef HIERARCHIC_PATHFINDER // {
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <setjmp.h>
|
||||
extern jmp_buf MainLoopJmpBuf;
|
||||
#endif
|
||||
|
||||
#define MOVEMENT_TYPE_TRANSPORTER 0
|
||||
#define MOVEMENT_TYPE_HOVERCRAFT 1
|
||||
|
@ -67,7 +100,7 @@ static MovementType MovementTypes[] = {
|
|||
/* MOVEMENT_TYPE_TRANSPORTER */
|
||||
{ MapFieldWaterAllowed | MapFieldCoastAllowed, 0, 0, NULL },
|
||||
/* MOVEMENT_TYPE_HOVERCRAFT */
|
||||
{ MapFieldWaterAllowed | MapFieldCoastAllowed | MapFieldLandAllowed,
|
||||
{ MapFieldWaterAllowed | MapFieldCoastAllowed | MapFieldLandAllowed,
|
||||
MapFieldForest, 0, NULL }
|
||||
};
|
||||
|
||||
|
@ -230,7 +263,7 @@ local void RegGroupSetDeleteGroup (RegGroup *group)
|
|||
group->NextInSet = NULL; /* just to be safe */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (p=RegGroupSet.Groups, g=p->NextInSet; g; p=g, g=g->NextInSet) {
|
||||
if (g != group) {
|
||||
continue;
|
||||
|
@ -517,7 +550,7 @@ local void SuperGroupDeleteRegGroup (SuperGroup *s, RegGroup *group)
|
|||
group->NextInSGroup[type] = NULL; /* just to be safe */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
p=s->RegGroups;
|
||||
g=p->NextInSGroup[type];
|
||||
for ( ; g; p=g, g=g->NextInSGroup[type]) {
|
||||
|
@ -802,3 +835,5 @@ local void PrintSuperGroupDescriptor (SuperGroup *sg)
|
|||
#endif
|
||||
|
||||
#endif // } HIERARCHIC_PATHFINDER
|
||||
|
||||
//@}
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
//----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#if DEBUG
|
||||
#if defined(DEBUG) && defined(HIERARCHIC_PATHFINDER)
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#endif /* DEBUG */
|
||||
#endif
|
||||
|
||||
#include "freecraft.h"
|
||||
#include "video.h"
|
||||
|
@ -60,7 +60,7 @@
|
|||
#include "settings.h"
|
||||
#include "commands.h"
|
||||
|
||||
#if defined(USE_SDLCD) || defined(USE_LIBCDA) || defined (USE_CDDA)
|
||||
#if defined(USE_SDLCD) || defined(USE_LIBCDA) || defined(USE_CDDA)
|
||||
#include "sound_server.h"
|
||||
#endif
|
||||
|
||||
|
@ -79,8 +79,8 @@ global enum _scroll_state_ KeyScrollState=ScrollNone;
|
|||
/// variable set when we are scrolling via mouse
|
||||
global enum _scroll_state_ MouseScrollState=ScrollNone;
|
||||
|
||||
#if DEBUG
|
||||
global jmp_buf main_loop;
|
||||
#if defined(DEBUG) && defined(HIERARCHIC_PATHFINDER)
|
||||
global jmp_buf MainLoopJmpBuf; /// Hierarchic pathfinder error exit.
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -164,7 +164,8 @@ local void MoveMapViewPointRight(int step)
|
|||
** @param fast Flag scroll faster.
|
||||
**
|
||||
** @todo Support dynamic acceleration of scroll speed.
|
||||
** If the scroll key is longer pressed the area is scrolled faster.
|
||||
** @todo If the scroll key is longer pressed the area is scrolled faster.
|
||||
** @todo Scrolling pixel wise.
|
||||
**
|
||||
** StephanR: above needs one row+column of tiles extra to be
|
||||
** drawn (clipped), which also needs to be supported
|
||||
|
@ -250,6 +251,10 @@ global void DebugTestDisplay(void)
|
|||
|
||||
/**
|
||||
** Draw menu button area.
|
||||
**
|
||||
** With debug it shows the used frame time and arrival of network packets.
|
||||
**
|
||||
** @todo Must be more configurable. Adding diplomacy menu here?
|
||||
*/
|
||||
local void DrawMenuButtonArea(void)
|
||||
{
|
||||
|
@ -627,8 +632,8 @@ global void GameMainLoop(void)
|
|||
MultiPlayerReplayEachCycle();
|
||||
|
||||
while( GameRunning ) {
|
||||
#if DEBUG
|
||||
if (setjmp (main_loop)) {
|
||||
#if defined(DEBUG) && defined(HIERARCHIC_PATHFINDER)
|
||||
if (setjmp (MainLoopJmpBuf)) {
|
||||
GamePaused = 1;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue