Skip to content

Commit

Permalink
21.7 child/baby ages fix
Browse files Browse the repository at this point in the history
- children and babies are now determined by their age relative to their
caste's child/baby age specification, instead of relying on the
profession name
- age in months is now always calculated, since it's sometimes used for
animal offspring
  • Loading branch information
splintermind committed Apr 27, 2014
1 parent 673196f commit 88cf834
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 52 deletions.
72 changes: 38 additions & 34 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#############################################################################
# Makefile for building: DwarfTherapist
# Generated by qmake (3.0) (Qt 5.1.1) on: Fri Apr 25 15:22:43 2014
# Generated by qmake (3.0) (Qt 5.1.1) on: Sun Apr 27 07:33:46 2014
# Project: dwarftherapist.pro
# Template: app
# Command: Z:\Qt\5.1.1\mingw48_32\bin\qmake.exe -spec win32-g++ -o Makefile dwarftherapist.pro
# Command: Z:\Qt\5.1.1\mingw48_32\bin\qmake.exe -spec win32-g++ CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile dwarftherapist.pro
#############################################################################

MAKEFILE = Makefile

first: release
install: release-install
uninstall: release-uninstall
first: debug
install: debug-install
uninstall: debug-uninstall
QMAKE = Z:\Qt\5.1.1\mingw48_32\bin\qmake.exe
DEL_FILE = del
CHK_DIR_EXISTS= if not exist
Expand All @@ -26,24 +26,10 @@ SYMLINK = copy /y
DEL_DIR = rmdir
MOVE = move
SUBTARGETS = \
release \
debug
debug \
release


release: FORCE
$(MAKE) -f $(MAKEFILE).Release
release-make_first: FORCE
$(MAKE) -f $(MAKEFILE).Release
release-all: FORCE
$(MAKE) -f $(MAKEFILE).Release all
release-clean: FORCE
$(MAKE) -f $(MAKEFILE).Release clean
release-distclean: FORCE
$(MAKE) -f $(MAKEFILE).Release distclean
release-install: FORCE
$(MAKE) -f $(MAKEFILE).Release install
release-uninstall: FORCE
$(MAKE) -f $(MAKEFILE).Release uninstall
debug: FORCE
$(MAKE) -f $(MAKEFILE).Debug
debug-make_first: FORCE
Expand All @@ -58,6 +44,20 @@ debug-install: FORCE
$(MAKE) -f $(MAKEFILE).Debug install
debug-uninstall: FORCE
$(MAKE) -f $(MAKEFILE).Debug uninstall
release: FORCE
$(MAKE) -f $(MAKEFILE).Release
release-make_first: FORCE
$(MAKE) -f $(MAKEFILE).Release
release-all: FORCE
$(MAKE) -f $(MAKEFILE).Release all
release-clean: FORCE
$(MAKE) -f $(MAKEFILE).Release clean
release-distclean: FORCE
$(MAKE) -f $(MAKEFILE).Release distclean
release-install: FORCE
$(MAKE) -f $(MAKEFILE).Release install
release-uninstall: FORCE
$(MAKE) -f $(MAKEFILE).Release uninstall

Makefile: dwarftherapist.pro ../../Qt/5.1.1/mingw48_32/mkspecs/win32-g++/qmake.conf ../../Qt/5.1.1/mingw48_32/mkspecs/features/spec_pre.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/qdevice.pri \
Expand Down Expand Up @@ -111,6 +111,8 @@ Makefile: dwarftherapist.pro ../../Qt/5.1.1/mingw48_32/mkspecs/win32-g++/qmake.c
../../Qt/5.1.1/mingw48_32/mkspecs/features/win32/default_pre.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/resolve_config.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/default_post.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/qml_debug.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/declarative_debug.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/win32/rtti.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/warn_on.prf \
../../Qt/5.1.1/mingw48_32/mkspecs/features/qt.prf \
Expand All @@ -129,7 +131,7 @@ Makefile: dwarftherapist.pro ../../Qt/5.1.1/mingw48_32/mkspecs/win32-g++/qmake.c
Z:/Qt/5.1.1/mingw48_32/lib/Qt5Network.prl \
Z:/Qt/5.1.1/mingw48_32/lib/Qt5Gui.prl \
Z:/Qt/5.1.1/mingw48_32/lib/Qt5Core.prl
$(QMAKE) -spec win32-g++ -o Makefile dwarftherapist.pro
$(QMAKE) -spec win32-g++ CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile dwarftherapist.pro
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\spec_pre.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\qdevice.pri:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\device_config.prf:
Expand Down Expand Up @@ -182,6 +184,8 @@ Makefile: dwarftherapist.pro ../../Qt/5.1.1/mingw48_32/mkspecs/win32-g++/qmake.c
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\win32\default_pre.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\resolve_config.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\default_post.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\qml_debug.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\declarative_debug.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\win32\rtti.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\warn_on.prf:
..\..\Qt\5.1.1\mingw48_32\mkspecs\features\qt.prf:
Expand All @@ -201,30 +205,30 @@ Z:/Qt/5.1.1/mingw48_32/lib/Qt5Network.prl:
Z:/Qt/5.1.1/mingw48_32/lib/Qt5Gui.prl:
Z:/Qt/5.1.1/mingw48_32/lib/Qt5Core.prl:
qmake: FORCE
@$(QMAKE) -spec win32-g++ -o Makefile dwarftherapist.pro
@$(QMAKE) -spec win32-g++ CONFIG+=debug CONFIG+=declarative_debug CONFIG+=qml_debug -o Makefile dwarftherapist.pro

qmake_all: FORCE

make_first: release-make_first debug-make_first FORCE
all: release-all debug-all FORCE
clean: release-clean debug-clean FORCE
distclean: release-distclean debug-distclean FORCE
make_first: debug-make_first release-make_first FORCE
all: debug-all release-all FORCE
clean: debug-clean release-clean FORCE
distclean: debug-distclean release-distclean FORCE
-$(DEL_FILE) Makefile

release-mocclean:
$(MAKE) -f $(MAKEFILE).Release mocclean
debug-mocclean:
$(MAKE) -f $(MAKEFILE).Debug mocclean
mocclean: release-mocclean debug-mocclean
release-mocclean:
$(MAKE) -f $(MAKEFILE).Release mocclean
mocclean: debug-mocclean release-mocclean

release-mocables:
$(MAKE) -f $(MAKEFILE).Release mocables
debug-mocables:
$(MAKE) -f $(MAKEFILE).Debug mocables
mocables: release-mocables debug-mocables
release-mocables:
$(MAKE) -f $(MAKEFILE).Release mocables
mocables: debug-mocables release-mocables

check: first
FORCE:

$(MAKEFILE).Release: Makefile
$(MAKEFILE).Debug: Makefile
$(MAKEFILE).Release: Makefile
2 changes: 2 additions & 0 deletions etc/memory_layouts/linux/v034.11.ini
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ caste_trait_ranges=0x01a4
caste_phys_att_ranges=0x0a5c
caste_att_rates=0x0c70
caste_att_caps=0x0da0
baby_age=0x00e8
child_age=0x00ec
adult_size=0x0100
flags=0x0258
extracts=0x1274
Expand Down
2 changes: 2 additions & 0 deletions etc/memory_layouts/osx/v034.11.ini
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ caste_trait_ranges=0x01a4
caste_phys_att_ranges=0x0a5c
caste_att_rates=0x0c70
caste_att_caps=0x0da0
baby_age=0x00e8
child_age=0x00ec
adult_size=0x0100
flags=0x0258
extracts=0x1274
Expand Down
2 changes: 2 additions & 0 deletions etc/memory_layouts/windows/v0.34.11_graphics.ini
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ caste_trait_ranges=0x04ec
caste_phys_att_ranges=0x0dd8
caste_att_rates=0x0fec
caste_att_caps=0x111c
baby_age=0x0430
child_age=0x0434
adult_size=0x0448
flags=0x05a0
extracts=0x2a30
Expand Down
2 changes: 2 additions & 0 deletions export-dt-ini.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ offset('caste_trait_ranges',df.caste_raw,'personality','a')
offset('caste_phys_att_ranges',df.caste_raw,'attributes','phys_att_range')
offset('caste_att_rates',df.caste_raw,'attributes','phys_att_rates')
offset('caste_att_caps',df.caste_raw,'attributes','phys_att_cap_perc')
offset('baby_age',df.caste_raw,'misc','baby_age')
offset('child_age',df.caste_raw,'misc','child_age')
offset('adult_size',df.caste_raw,'misc','adult_size')
offset('flags',df.caste_raw,'flags')
vector('extracts',df.caste_raw,'extracts','extract_matidx')
Expand Down
5 changes: 5 additions & 0 deletions inc/caste.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class Caste : public QObject {
int child_size() {return get_body_size(0) / 2;} //get_body_size(1);}
int baby_size() {return get_body_size(0) / 4;} //get_body_size(2);}

int child_age() {return m_child_age;}
int baby_age() {return m_baby_age;}

void load_data();
void load_skill_rates();

Expand All @@ -88,6 +91,8 @@ class Caste : public QObject {
QString m_name_plural;
QString m_description;
QVector<int> m_body_sizes;
int m_baby_age;
int m_child_age;

QHash<int,att_range> m_attrib_ranges;

Expand Down
2 changes: 1 addition & 1 deletion inc/dwarf.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ class Dwarf : public QObject
QString read_chunked_name(const VIRTADDR &addr, bool use_generic=false);

// assembles component names into a nicely formatted single string
void calc_names();
void build_names();

signals:
void name_changed();
Expand Down
2 changes: 1 addition & 1 deletion src/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ AboutDialog::AboutDialog(MainWindow *parent)
, m_version(Version())
{
ui->setupUi(this);
ui->lbl_our_version->setText(QString("VERSION %1 - BRANCH VERSION %2").arg(m_version.to_string()).arg("21.6"));
ui->lbl_our_version->setText(QString("VERSION %1 - BRANCH VERSION %2").arg(m_version.to_string()).arg("21.7"));
connect(ui->pb_check_version, SIGNAL(clicked()), SLOT(check_version()));
}

Expand Down
4 changes: 4 additions & 0 deletions src/caste.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Caste::Caste(DFInstance *df, VIRTADDR address, Race *r, QObject *parent)
, m_name(QString::null)
, m_name_plural(QString::null)
, m_description(QString::null)
, m_baby_age(0)
, m_child_age(0)
, m_df(df)
, m_mem(df->memory_layout())
, m_flags()
Expand Down Expand Up @@ -87,6 +89,8 @@ void Caste::read_caste() {
// m_body_sizes.prepend((int)size);
// }
m_body_sizes.append(m_df->read_int(m_address + m_mem->caste_offset("adult_size")));
m_baby_age = m_df->read_int(m_address + m_mem->caste_offset("baby_age"));
m_child_age = m_df->read_int(m_address + m_mem->caste_offset("child_age"));
m_flags = FlagArray(m_df, m_address + m_mem->caste_offset("flags"));

QVector<uint> extracts = m_df->enumerate_vector(m_address + m_mem->caste_offset("extracts"));
Expand Down
33 changes: 17 additions & 16 deletions src/dwarf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void Dwarf::read_settings() {
QSettings *s = DT->user_settings();
bool new_show_full_name = s->value("options/show_full_dwarf_names",false).toBool();
if (new_show_full_name != m_show_full_name) {
calc_names();
build_names();
emit name_changed();
}
m_show_full_name = new_show_full_name;
Expand Down Expand Up @@ -272,7 +272,7 @@ void Dwarf::refresh_data() {
read_first_name();
read_last_name(m_address + m_mem->dwarf_offset("first_name"));
read_nick_name();
calc_names(); //creates nice name.. which is used for debug messages so we need to do it first..
build_names(); //creates nice name.. which is used for debug messages so we need to do it first..
read_states(); //read states before job
read_mood(); //read before skills (soul aspect)
read_soul();
Expand All @@ -281,17 +281,17 @@ void Dwarf::refresh_data() {
if(!m_validated)
this->is_valid();
if(m_is_valid){
read_caste();
read_caste(); //read before age
read_profession();
read_body_size();
read_labors();
read_happiness();
read_squad_info(); //read squad before job
read_uniform();
read_current_job();
read_syndromes(); //read syndromes before attributes
read_turn_count(); //load time/date stuff for births/migrations - read before age
set_age_and_migration(m_address + m_mem->dwarf_offset("birth_year"), m_address + m_mem->dwarf_offset("birth_time"));
set_age_and_migration(m_address + m_mem->dwarf_offset("birth_year"), m_address + m_mem->dwarf_offset("birth_time")); //set age before profession
read_body_size(); //body size after caste and age
//curse check will change the name and age
read_curse(); //read curse before attributes
read_soul_aspects(); //assumes soul already read, and requires caste to be read first
Expand All @@ -310,7 +310,7 @@ void Dwarf::refresh_data() {
read_inventory();

if(m_is_animal)
calc_names(); //calculate names again as we need to check tameness for animals
build_names(); //calculate names again as we need to check tameness for animals

//currently only flags used are for cage and butcher animal
m_caged = flags1;
Expand Down Expand Up @@ -413,8 +413,14 @@ void Dwarf::set_age_and_migration(VIRTADDR birth_year_offset, VIRTADDR birth_tim
m_migration_wave = 100000 * arrival_year + 10000 * arrival_season + 100 * arrival_month + arrival_day;
m_born_in_fortress = (time_since_birth == m_turn_count);

if(m_age == 0)
m_age_in_months = time_since_birth / ticks_per_month;
m_age_in_months = time_since_birth / ticks_per_month;

if(m_caste){
if(m_age == 0 || time_since_birth < m_caste->baby_age() * ticks_per_year)
m_is_baby = true;
else if(time_since_birth < m_caste->child_age() * ticks_per_year)
m_is_child = true;
}
}

QString Dwarf::get_migration_desc(){
Expand Down Expand Up @@ -604,7 +610,7 @@ void Dwarf::find_true_ident(){
m_fake_nickname = fake_id + m_mem->hist_figure_offset("fake_name") + m_mem->dwarf_offset("nick_name");
m_nick_name = m_df->read_string(m_fake_nickname);
read_last_name(fake_id + m_mem->hist_figure_offset("fake_name"));
calc_names();
build_names();
//vamps also use a fake age
set_age_and_migration(fake_id + m_mem->hist_figure_offset("fake_birth_year"),fake_id + m_mem->hist_figure_offset("fake_birth_time"));
}
Expand Down Expand Up @@ -694,7 +700,7 @@ void Dwarf::read_nick_name() {
m_hist_nickname = hist_addr + m_mem->hist_figure_offset("hist_name") + m_mem->dwarf_offset("nick_name");
}

void Dwarf::calc_names() {
void Dwarf::build_names() {
if (m_pending_nick_name.isEmpty()) {
m_nice_name = QString("%1 %2").arg(m_first_name, m_last_name);
m_translated_name = QString("%1 %2").arg(m_first_name, m_translated_last_name);
Expand Down Expand Up @@ -794,11 +800,6 @@ void Dwarf::read_profession() {
TRACE << "reading profession for" << nice_name() << m_raw_profession <<
prof_name;
TRACE << "EFFECTIVE PROFESSION:" << m_profession;

if(m_profession == tr("Child"))
m_is_child = true;
else if (m_profession == tr("Baby"))
m_is_baby = true;
}

void Dwarf::read_noble_position(){
Expand Down Expand Up @@ -1978,7 +1979,7 @@ void Dwarf::recheck_equipment(){

void Dwarf::set_nickname(const QString &nick) {
m_pending_nick_name = nick;
calc_names();
build_names();
}

void Dwarf::set_custom_profession_text(const QString &prof_text) {
Expand Down

0 comments on commit 88cf834

Please sign in to comment.