Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d5d4875

Browse files
committed
Make things work properly.
1 parent 0375be5 commit d5d4875

14 files changed

Lines changed: 56 additions & 205 deletions

File tree

library/Console-linux.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ bool Console::init(bool sharing)
653653
FD_SET(STDIN_FILENO, &d->descriptor_set);
654654
FD_SET(d->exit_pipe[0], &d->descriptor_set);
655655
inited = true;
656+
return true;
656657
}
657658

658659
bool Console::shutdown(void)

library/include/modules/Maps.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,13 @@ typedef int16_t t_blockmaterials [16][16];
145145
* \ingroup grp_maps
146146
*/
147147
typedef df::tile_designation designations40d [16][16];
148+
typedef df::tile_designation t_designation;
148149
/**
149150
* 16x16 array of occupancy flags
150151
* \ingroup grp_maps
151152
*/
152153
typedef df::tile_occupancy occupancies40d [16][16];
154+
typedef df::tile_occupancy t_occupancy;
153155
/**
154156
* array of 16 biome indexes valid for the block
155157
* \ingroup grp_maps

library/include/modules/Units.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ DFHACK_EXPORT bool isValid();
169169
/* Read Functions */
170170
// Read creatures in a box, starting with index. Returns -1 if no more creatures
171171
// found. Call repeatedly do get all creatures in a specified box (uses tile coords)
172+
DFHACK_EXPORT int32_t getNumCreatures();
172173
DFHACK_EXPORT int32_t GetCreatureInBox(const int32_t index, df::unit ** furball,
173174
const uint16_t x1, const uint16_t y1,const uint16_t z1,
174175
const uint16_t x2, const uint16_t y2,const uint16_t z2);

library/modules/Materials.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ using namespace std;
6262

6363
#include "df/physical_attribute_type.h"
6464
#include "df/mental_attribute_type.h"
65+
#include <df/color_modifier_raw.h>
6566

6667
using namespace DFHack;
6768
using namespace df::enums;
@@ -746,32 +747,32 @@ bool Materials::ReadCreatureTypesEx (void)
746747
caste.singular = ca->caste_name[0];
747748
caste.plural = ca->caste_name[1];
748749
caste.adjective = ca->caste_name[2];
749-
/*
750+
750751
// color mod reading
751752
// Caste + offset > color mod vector
752-
vector <char *> & p_colormod = *(vector<char*> *) (world->raws.creatures.all[i]->caste + caste_colormod_offset);
753-
uint32_t sizecolormod = p_colormod.size();
753+
auto & colorings = ca->color_modifiers;
754+
uint32_t sizecolormod = colorings.size();
754755
caste.ColorModifier.resize(sizecolormod);
755756
for(uint32_t k = 0; k < sizecolormod;k++)
756757
{
757758
// color mod [0] -> color list
758-
vector <uint32_t> & p_colorlist = *(vector<uint32_t> *) (p_colormod[k]);
759-
uint32_t sizecolorlist = p_colorlist.size();
759+
auto & indexes = colorings[k]->color_indexes;
760+
uint32_t sizecolorlist = indexes.size();
760761
caste.ColorModifier[k].colorlist.resize(sizecolorlist);
761762
for(uint32_t l = 0; l < sizecolorlist; l++)
762-
caste.ColorModifier[k].colorlist[l] = p_colorlist[l];
763+
caste.ColorModifier[k].colorlist[l] = indexes[l];
763764
// color mod [color_modifier_part_offset] = string part
764-
caste.ColorModifier[k].part = p->readSTLString( p_colormod[k] + color_modifier_part_offset);
765-
caste.ColorModifier[k].startdate = p->readDWord( p_colormod[k] + color_modifier_startdate_offset );
766-
caste.ColorModifier[k].enddate = p->readDWord( p_colormod[k] + color_modifier_enddate_offset );
765+
caste.ColorModifier[k].part = colorings[k]->part;
766+
caste.ColorModifier[k].startdate = colorings[k]->start_date;
767+
caste.ColorModifier[k].enddate = colorings[k]->end_date;
767768
}
768-
*/
769+
769770
// body parts
770771
caste.bodypart.empty();
771-
uint32_t sizebp = ca->body_parts.size();
772+
uint32_t sizebp = ca->unknown1.body_parts.size();
772773
for (uint32_t k = 0; k < sizebp; k++)
773774
{
774-
df::body_part_raw *bp = ca->body_parts[k];
775+
df::body_part_raw *bp = ca->unknown1.body_parts[k];
775776
t_bodypart part;
776777
part.id = bp->part_code;
777778
part.category = bp->part_name;

library/modules/Units.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ bool Units::isValid()
5959
return (world->units.all.size() > 0);
6060
}
6161

62+
int32_t Units::getNumCreatures()
63+
{
64+
return world->units.all.size();
65+
}
66+
6267
df::unit * Units::GetCreature (const int32_t index)
6368
{
6469
if (!isValid()) return NULL;

library/xml

Submodule xml updated from 7082ed1 to 6359571

plugins/devel/buildprobe.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ DFhackCExport DFHack::command_result readFlag (Core * c, vector <string> & param
4343
{
4444
c->Suspend();
4545

46-
DFHack::Maps * Maps = c->getMaps();
4746
DFHack::Gui * Gui = c->getGui();
4847
// init the map
49-
if(!Maps->Start())
48+
if(!Maps::IsValid())
5049
{
5150
c->con.printerr("Can't init map. Make sure you have a map loaded in DF.\n");
5251
c->Resume();
@@ -64,7 +63,7 @@ DFhackCExport DFHack::command_result readFlag (Core * c, vector <string> & param
6463

6564
DFHack::DFCoord cursor = DFHack::DFCoord(cx,cy,cz);
6665

67-
MapExtras::MapCache * MCache = new MapExtras::MapCache(Maps);
66+
MapExtras::MapCache * MCache = new MapExtras::MapCache();
6867
DFHack::t_occupancy oc = MCache->occupancyAt(cursor);
6968

7069
c->con.print("Current Value: %d\n", oc.bits.building);
@@ -111,10 +110,9 @@ DFhackCExport DFHack::command_result writeFlag (Core * c, vector <string> & para
111110

112111
c->Suspend();
113112

114-
DFHack::Maps * Maps = c->getMaps();
115113
DFHack::Gui * Gui = c->getGui();
116114
// init the map
117-
if(!Maps->Start())
115+
if(!Maps::IsValid())
118116
{
119117
c->con.printerr("Can't init map. Make sure you have a map loaded in DF.\n");
120118
c->Resume();
@@ -132,7 +130,7 @@ DFhackCExport DFHack::command_result writeFlag (Core * c, vector <string> & para
132130

133131
DFHack::DFCoord cursor = DFHack::DFCoord(cx,cy,cz);
134132

135-
MapExtras::MapCache * MCache = new MapExtras::MapCache(Maps);
133+
MapExtras::MapCache * MCache = new MapExtras::MapCache();
136134
DFHack::t_occupancy oc = MCache->occupancyAt(cursor);
137135

138136
oc.bits.building = value;

plugins/devel/itemhacks.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ using namespace DFHack;
1515
//////////////////////
1616
// START item choosers
1717
//////////////////////
18-
18+
/*
1919
class item_chooser
2020
{
2121
public:
22-
item_chooser(Core* _c, DFHack::Items* _Items) : c(_c), Items(_Items)
22+
item_chooser(Core* _c) : c(_c)
2323
{
2424
}
2525
@@ -31,13 +31,12 @@ class item_chooser
3131
3232
protected:
3333
Core *c;
34-
DFHack::Items *Items;
3534
};
3635
3736
class choose_all : public item_chooser
3837
{
3938
public:
40-
choose_all(Core* _c, ::Items* _Items) : item_chooser(_c, _Items)
39+
choose_all(Core* _c) : item_chooser(_c)
4140
{
4241
}
4342
@@ -51,7 +50,7 @@ class choose_all : public item_chooser
5150
class choose_unknown : public item_chooser
5251
{
5352
public:
54-
choose_unknown(Core* _c, ::Items* _Items) : item_chooser(_c, _Items)
53+
choose_unknown(Core* _c) : item_chooser(_c)
5554
{
5655
}
5756
@@ -66,9 +65,8 @@ class choose_unknown : public item_chooser
6665
6766
t_itemflags &f = itm->origin->flags;
6867
69-
return (f.unk1 || f.unk2 || f.unk3 || f.unk4 || /*f.unk5 ||*/
68+
return (f.unk1 || f.unk2 || f.unk3 || f.unk4 ||
7069
f.unk6 || f.unk7 ||
71-
// f.unk8 || f.unk9 || /* Too common */
7270
f.unk10 || f.unk11);
7371
}
7472
@@ -263,6 +261,7 @@ DFhackCExport command_result df_dumpitems (Core * c, vector <string> & parameter
263261
}
264262
}
265263
*/
264+
/*
266265
}
267266
c->Resume();
268267
@@ -271,3 +270,4 @@ DFhackCExport command_result df_dumpitems (Core * c, vector <string> & parameter
271270
272271
return CR_OK;
273272
}
273+
*/

0 commit comments

Comments
 (0)