Skip to content

Commit

Permalink
Remove npc.h from mission.h
Browse files Browse the repository at this point in the history
  • Loading branch information
Coolthulhu committed Feb 13, 2016
1 parent 2a39170 commit f357934
Show file tree
Hide file tree
Showing 17 changed files with 268 additions and 170 deletions.
1 change: 1 addition & 0 deletions CataclysmWin.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@
<Unit filename="src/nonplayer.h" />
<Unit filename="src/npc.cpp" />
<Unit filename="src/npc.h" />
<Unit filename="src/npc_favor.h" />
<Unit filename="src/npcmove.cpp" />
<Unit filename="src/npctalk.cpp" />
<Unit filename="src/omdata.h" />
Expand Down
1 change: 1 addition & 0 deletions astyled_whitelist
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ src/mongroup.h
src/morale.h
src/mutation.h
src/name.h
src/npc_favor.h
src/nonplayer.h
src/omdata.h
src/options.h
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ SET (CATACLYSM_DDA_HEADERS
${CMAKE_SOURCE_DIR}/src/item_location.h
${CMAKE_SOURCE_DIR}/src/map.h
${CMAKE_SOURCE_DIR}/src/npc.h
${CMAKE_SOURCE_DIR}/src/npc_favor.h
${CMAKE_SOURCE_DIR}/src/rng.h
${CMAKE_SOURCE_DIR}/src/compatibility.h
${CMAKE_SOURCE_DIR}/src/faction.h
Expand Down
10 changes: 5 additions & 5 deletions src/faction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,17 +496,17 @@ void faction::make_army()
id = "army";
}

bool faction::has_job(faction_job j)
bool faction::has_job(faction_job j) const
{
return (job1 == j || job2 == j);
}

bool faction::has_value(faction_value v)
bool faction::has_value(faction_value v) const
{
return values & mfb(v);
}

bool faction::matches_us(faction_value v)
bool faction::matches_us(faction_value v) const
{
int numvals = 2;
if (job2 != FACJOB_NULL) {
Expand Down Expand Up @@ -552,7 +552,7 @@ bool faction::matches_us(faction_value v)
return false;
}

std::string faction::describe()
std::string faction::describe() const
{
std::string ret;
ret = desc + "\n \n" + string_format( _("%1$s have the ultimate goal of %2$s."), name.c_str(),
Expand Down Expand Up @@ -583,7 +583,7 @@ std::string faction::describe()
return ret;
}

int faction::response_time()
int faction::response_time() const
{
int base = abs(mapx - g->get_levx());
if (abs(mapy - g->get_levy()) > base) {
Expand Down
10 changes: 5 additions & 5 deletions src/faction.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ class faction : public JsonSerializer, public JsonDeserializer

void randomize();
void make_army();
bool has_job( faction_job j );
bool has_value( faction_value v );
bool matches_us( faction_value v );
std::string describe();
bool has_job( faction_job j ) const;
bool has_value( faction_value v ) const;
bool matches_us( faction_value v ) const;
std::string describe() const;

int response_time(); // Time it takes for them to get to u
int response_time() const; // Time it takes for them to get to u

std::string name;
unsigned values :
Expand Down
46 changes: 46 additions & 0 deletions src/mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "requirements.h"
#include "overmap.h"
#include "line.h"
#include "npc.h"

#include <fstream>
#include <sstream>
Expand Down Expand Up @@ -2504,3 +2505,48 @@ Before we get into a major fight just make sure we have the gear we need, boss."
return string_format( "Someone forgot to code this message id is %d, topic is %s!", static_cast<int>( id ), state.c_str() );
}

mission::mission()
{
type = NULL;
description = "";
failed = false;
value = 0;
uid = -1;
target = tripoint(INT_MIN, INT_MIN, INT_MIN);
item_id = "null";
item_count = 1;
target_id = 0;
recruit_class = NC_NONE;
target_npc_id = -1;
monster_type = "mon_null";
monster_kill_goal = -1;
deadline = 0;
npc_id = -1;
good_fac_id = -1;
bad_fac_id = -1;
step = 0;
player_id = -1;
was_started = false;
}

mission_type::mission_type(mission_type_id ID, std::string NAME, mission_goal GOAL, int DIF, int VAL,
bool URGENT,
bool (mission_place::*PLACE)( const tripoint& ),
void (mission_start::*START)(mission *),
void (mission_end ::*END )(mission *),
void (mission_fail ::*FAIL )(mission *)) :
id (ID), name (NAME), goal (GOAL), difficulty (DIF), value (VAL),
urgent(URGENT), place (PLACE), start (START), end (END), fail (FAIL)
{
deadline_low = 0;
deadline_high = 0;
item_id = "null";
item_count = 1;
target_id = 0;///(0);// = "";
recruit_class = NC_NONE;
target_npc_id = -1;
monster_type = "mon_null";
monster_kill_goal = -1;
follow_up = MISSION_NULL;
};

49 changes: 9 additions & 40 deletions src/mission.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
#include <unordered_map>
#include "omdata.h"
#include "itype.h"
#include "npc.h"
#include "json.h"
#include "npc_favor.h"

class mission;
class game;
class npc;
class Creature;
class calendar;

enum npc_class : int;
enum npc_mission : int;

enum mission_type_id {
MISSION_NULL,
Expand Down Expand Up @@ -247,21 +253,7 @@ struct mission_type {
bool (mission_place::*PLACE)( const tripoint& ),
void (mission_start::*START)(mission *),
void (mission_end ::*END )(mission *),
void (mission_fail ::*FAIL )(mission *)) :
id (ID), name (NAME), goal (GOAL), difficulty (DIF), value (VAL),
urgent(URGENT), place (PLACE), start (START), end (END), fail (FAIL)
{
deadline_low = 0;
deadline_high = 0;
item_id = "null";
item_count = 1;
target_id = 0;///(0);// = "";
recruit_class = NC_NONE;
target_npc_id = -1;
monster_type = "mon_null";
monster_kill_goal = -1;
follow_up = MISSION_NULL;
};
void (mission_fail ::*FAIL )(mission *));

mission create( int npc_id ) const;

Expand Down Expand Up @@ -329,30 +321,7 @@ class mission : public JsonSerializer, public JsonDeserializer
using JsonDeserializer::deserialize;
void deserialize(JsonIn &jsin) override;

mission()
{
type = NULL;
description = "";
failed = false;
value = 0;
uid = -1;
target = tripoint(INT_MIN, INT_MIN, INT_MIN);
item_id = "null";
item_count = 1;
target_id = 0;
recruit_class = NC_NONE;
target_npc_id = -1;
monster_type = "mon_null";
monster_kill_goal = -1;
deadline = 0;
npc_id = -1;
good_fac_id = -1;
bad_fac_id = -1;
step = 0;
player_id = -1;
was_started = false;
}

mission();
/** Getters, they mostly return the member directly, mostly. */
/*@{*/
bool has_deadline() const;
Expand Down
1 change: 1 addition & 0 deletions src/mission_end.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "map.h"
#include "translations.h"
#include "messages.h"
#include "npc.h"

const efftype_id effect_infection( "infection" );

Expand Down
1 change: 1 addition & 0 deletions src/mission_fail.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "mission.h"
#include "game.h"
#include "overmapbuffer.h"
#include "npc.h"

void mission_fail::kill_npc( mission *miss )
{
Expand Down
1 change: 1 addition & 0 deletions src/mission_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// TODO: Remove this include once 2D wrappers are no longer needed
#include "mapgen_functions.h"
#include "field.h"
#include "npc.h"

const mtype_id mon_charred_nightmare( "mon_charred_nightmare" );
const mtype_id mon_dog( "mon_dog" );
Expand Down
1 change: 1 addition & 0 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "mtype.h"
#include "field.h"
#include "sounds.h"
#include "npc.h"

#define SGN(a) (((a)<0) ? -1 : 1)
#define SQR(a) ((a)*(a))
Expand Down
Loading

0 comments on commit f357934

Please sign in to comment.