|
|
|
@ -992,21 +992,21 @@ bool API::ReadNote (const int32_t &index, t_note & note)
|
|
|
|
|
}
|
|
|
|
|
bool API::InitReadSettlements( uint32_t & numsettlements )
|
|
|
|
|
{
|
|
|
|
|
memory_info * minfo = d->offset_descriptor;
|
|
|
|
|
memory_info * minfo = d->offset_descriptor;
|
|
|
|
|
int allSettlements = minfo->getAddress ("settlements");
|
|
|
|
|
int currentSettlement = minfo->getAddress("settlement_current");
|
|
|
|
|
int currentSettlement = minfo->getAddress("settlement_current");
|
|
|
|
|
d->settlement_name_offset = minfo->getOffset ("settlement_name");
|
|
|
|
|
d->settlement_world_xy_offset = minfo->getOffset ("settlement_world_xy");
|
|
|
|
|
d->settlement_local_xy_offset = minfo->getOffset ("settlement_local_xy");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (allSettlements && currentSettlement
|
|
|
|
|
&& d->settlement_name_offset
|
|
|
|
|
&& d->settlement_world_xy_offset
|
|
|
|
|
&& d->settlement_local_xy_offset
|
|
|
|
|
&& d->settlement_world_xy_offset
|
|
|
|
|
&& d->settlement_local_xy_offset
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
d->p_settlements = new DfVector (d->p->readVector (allSettlements, 4));
|
|
|
|
|
d->p_current_settlement = new DfVector(d->p->readVector(currentSettlement,4));
|
|
|
|
|
d->p_current_settlement = new DfVector(d->p->readVector(currentSettlement,4));
|
|
|
|
|
d->settlementsInited = true;
|
|
|
|
|
numsettlements = d->p_settlements->getSize();
|
|
|
|
|
return true;
|
|
|
|
@ -1017,37 +1017,41 @@ bool API::InitReadSettlements( uint32_t & numsettlements )
|
|
|
|
|
numsettlements = 0;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bool API::ReadSettlement(const int32_t &index, t_settlement & settlement)
|
|
|
|
|
{
|
|
|
|
|
if(!d->settlementsInited)
|
|
|
|
|
if(!d->settlementsInited)
|
|
|
|
|
return false;
|
|
|
|
|
if(!d->p_settlements->getSize())
|
|
|
|
|
return false;
|
|
|
|
|
// read pointer from vector at position
|
|
|
|
|
uint32_t temp = * (uint32_t *) d->p_settlements->at (index);
|
|
|
|
|
settlement.origin = temp;
|
|
|
|
|
settlement.origin = temp;
|
|
|
|
|
g_pProcess->read(temp + d->settlement_name_offset, 2 * sizeof(int32_t), (uint8_t *) &settlement.name);
|
|
|
|
|
g_pProcess->read(temp + d->settlement_world_xy_offset, 2 * sizeof(int16_t), (uint8_t *) &settlement.world_x);
|
|
|
|
|
g_pProcess->read(temp + d->settlement_local_xy_offset, 4 * sizeof(int16_t), (uint8_t *) &settlement.local_x1);
|
|
|
|
|
g_pProcess->read(temp + d->settlement_world_xy_offset, 2 * sizeof(int16_t), (uint8_t *) &settlement.world_x);
|
|
|
|
|
g_pProcess->read(temp + d->settlement_local_xy_offset, 4 * sizeof(int16_t), (uint8_t *) &settlement.local_x1);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
bool API::ReadCurrentSettlement(t_settlement & settlement)
|
|
|
|
|
{
|
|
|
|
|
if(!d->settlementsInited)
|
|
|
|
|
return false;
|
|
|
|
|
if(!d->settlementsInited)
|
|
|
|
|
return false;
|
|
|
|
|
if(!d->p_current_settlement->getSize())
|
|
|
|
|
return false;
|
|
|
|
|
uint32_t temp = * (uint32_t *) d->p_current_settlement->at(0);
|
|
|
|
|
settlement.origin = temp;
|
|
|
|
|
g_pProcess->read(temp + d->settlement_name_offset, 2 * sizeof(int32_t), (uint8_t *) &settlement.name);
|
|
|
|
|
g_pProcess->read(temp + d->settlement_world_xy_offset, 2 * sizeof(int32_t), (uint8_t *) &settlement.world_x);
|
|
|
|
|
g_pProcess->read(temp + d->settlement_local_xy_offset, 4 * sizeof(int32_t), (uint8_t *) &settlement.local_x1);
|
|
|
|
|
settlement.origin = temp;
|
|
|
|
|
g_pProcess->read(temp + d->settlement_name_offset, 2 * sizeof(int32_t), (uint8_t *) &settlement.name);
|
|
|
|
|
g_pProcess->read(temp + d->settlement_world_xy_offset, 2 * sizeof(int16_t), (uint8_t *) &settlement.world_x);
|
|
|
|
|
g_pProcess->read(temp + d->settlement_local_xy_offset, 4 * sizeof(int16_t), (uint8_t *) &settlement.local_x1);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void API::FinishReadSettlements()
|
|
|
|
|
{
|
|
|
|
|
delete d->p_settlements;
|
|
|
|
|
delete d->p_current_settlement;
|
|
|
|
|
delete d->p_current_settlement;
|
|
|
|
|
d->p_settlements = NULL;
|
|
|
|
|
d->p_current_settlement = NULL;
|
|
|
|
|
d->p_current_settlement = NULL;
|
|
|
|
|
d->settlementsInited = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|