implement matrix and move containers into their own directory
This commit is contained in:
parent
1378f2c7dd
commit
7fe30185df
174
reference/game.c
174
reference/game.c
@ -16459,63 +16459,6 @@ void _GLOBAL__I_InstanceAttributeNames(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DWARF original prototype: void matrix3d(matrix3d<TSector*> * this, int xmin, int xmax, int ymin,
|
|
||||||
// int ymax, int zmin, int zmax, TSector * init)
|
|
||||||
|
|
||||||
void __thiscall
|
|
||||||
matrix3d<TSector*>::matrix3d
|
|
||||||
(matrix3d<TSector*> *this,int xmin,int xmax,int ymin,int ymax,int zmin,int zmax,
|
|
||||||
TSector *init)
|
|
||||||
|
|
||||||
{
|
|
||||||
int iVar1;
|
|
||||||
TSector **ppTVar2;
|
|
||||||
int iVar3;
|
|
||||||
int i;
|
|
||||||
int iVar4;
|
|
||||||
|
|
||||||
this->xmin = xmin;
|
|
||||||
this->ymin = ymin;
|
|
||||||
this->zmin = zmin;
|
|
||||||
iVar4 = (xmax - xmin) + 1;
|
|
||||||
this->dx = iVar4;
|
|
||||||
iVar3 = (ymax - ymin) + 1;
|
|
||||||
this->dy = iVar3;
|
|
||||||
iVar1 = (zmax - zmin) + 1;
|
|
||||||
this->dz = iVar1;
|
|
||||||
if (((iVar4 < 1) || (iVar3 < 1)) || (iVar1 < 1)) {
|
|
||||||
error("matrix3d: Ungueltige Feldgroesse %d..%d, %d..%d, %d..%d.\n",xmin,xmax,ymin,ymax,zmin,
|
|
||||||
zmax);
|
|
||||||
iVar4 = this->dx;
|
|
||||||
if (iVar4 < 1) {
|
|
||||||
this->dx = 1;
|
|
||||||
iVar4 = 1;
|
|
||||||
}
|
|
||||||
iVar3 = this->dy;
|
|
||||||
if (iVar3 < 1) {
|
|
||||||
this->dy = 1;
|
|
||||||
iVar3 = 1;
|
|
||||||
}
|
|
||||||
iVar1 = this->dz;
|
|
||||||
if (iVar1 < 1) {
|
|
||||||
this->dz = 1;
|
|
||||||
iVar1 = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ppTVar2 = (TSector **)operator_new__(iVar4 * iVar3 * iVar1 * 4);
|
|
||||||
iVar4 = 0;
|
|
||||||
this->entry = ppTVar2;
|
|
||||||
if (0 < this->dy * this->dx * this->dz) {
|
|
||||||
do {
|
|
||||||
this->entry[iVar4] = init;
|
|
||||||
iVar4 = iVar4 + 1;
|
|
||||||
} while (iVar4 < this->dy * this->dx * this->dz);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void __static_initialization_and_destruction_0(int __initialize_p,int __priority)
|
void __static_initialization_and_destruction_0(int __initialize_p,int __priority)
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -28294,43 +28237,6 @@ void _GLOBAL__I__Z7GetName6Object(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// DWARF original prototype: void matrix(matrix<int> * this, int xmin, int xmax, int ymin, int ymax)
|
|
||||||
|
|
||||||
void __thiscall matrix<int>::matrix(matrix<int> *this,int xmin,int xmax,int ymin,int ymax)
|
|
||||||
|
|
||||||
{
|
|
||||||
int iVar1;
|
|
||||||
int *piVar2;
|
|
||||||
int iVar3;
|
|
||||||
|
|
||||||
iVar3 = (xmax - xmin) + 1;
|
|
||||||
this->xmin = xmin;
|
|
||||||
iVar1 = (ymax - ymin) + 1;
|
|
||||||
this->ymin = ymin;
|
|
||||||
this->dx = iVar3;
|
|
||||||
this->dy = iVar1;
|
|
||||||
if ((iVar3 < 1) || (iVar1 < 1)) {
|
|
||||||
error("matrix: Ungueltige Feldgroesse %d..%d, %d..%d.\n",xmin,xmax,ymin,ymax);
|
|
||||||
iVar3 = this->dx;
|
|
||||||
if (iVar3 < 1) {
|
|
||||||
this->dx = 1;
|
|
||||||
iVar3 = 1;
|
|
||||||
}
|
|
||||||
iVar1 = this->dy;
|
|
||||||
if (iVar1 < 1) {
|
|
||||||
this->dy = 1;
|
|
||||||
iVar1 = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
piVar2 = (int *)operator_new__(iVar3 * iVar1 * 4);
|
|
||||||
this->entry = piVar2;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void RandomShuffle<int>(int *Buffer,int Size)
|
void RandomShuffle<int>(int *Buffer,int Size)
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -56434,40 +56340,6 @@ void __thiscall TCreature::AttackStimulus(TCreature *this,ulong param_1)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DWARF original prototype: void matrix(matrix<long_unsigned_int> * this, int xmin, int xmax, int
|
|
||||||
// ymin, int ymax, ulong init)
|
|
||||||
|
|
||||||
void __thiscall matrix<>::matrix(matrix<> *this,int xmin,int xmax,int ymin,int ymax,ulong init)
|
|
||||||
|
|
||||||
{
|
|
||||||
int iVar1;
|
|
||||||
ulong *puVar2;
|
|
||||||
int i;
|
|
||||||
int iVar3;
|
|
||||||
|
|
||||||
iVar3 = (xmax - xmin) + 1;
|
|
||||||
iVar1 = (ymax - ymin) + 1;
|
|
||||||
this->dy = iVar1;
|
|
||||||
this->xmin = xmin;
|
|
||||||
this->ymin = ymin;
|
|
||||||
this->dx = iVar3;
|
|
||||||
if ((iVar3 < 1) || (iVar1 < 1)) {
|
|
||||||
error("matrix: Ungueltige Feldgroesse %d..%d, %d..%d.\n",xmin,xmax,ymin,ymax);
|
|
||||||
this->dx = 1;
|
|
||||||
this->dy = 1;
|
|
||||||
}
|
|
||||||
puVar2 = (ulong *)operator_new__(this->dy * this->dx * 4);
|
|
||||||
iVar1 = 0;
|
|
||||||
this->entry = puVar2;
|
|
||||||
if (0 < this->dy * this->dx) {
|
|
||||||
do {
|
|
||||||
this->entry[iVar1] = init;
|
|
||||||
iVar1 = iVar1 + 1;
|
|
||||||
} while (iVar1 < this->dy * this->dx);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void __static_initialization_and_destruction_0(int __initialize_p,int __priority)
|
void __static_initialization_and_destruction_0(int __initialize_p,int __priority)
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -73694,52 +73566,6 @@ void _GLOBAL__I__ZN9TShortwayC2EP9TCreatureii(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// DWARF original prototype: void matrix(matrix<TShortwayPoint> * this, int xmin, int xmax, int
|
|
||||||
// ymin, int ymax)
|
|
||||||
|
|
||||||
void __thiscall matrix<>::matrix(matrix<> *this,int xmin,int xmax,int ymin,int ymax)
|
|
||||||
|
|
||||||
{
|
|
||||||
int iVar1;
|
|
||||||
TShortwayPoint *pTVar2;
|
|
||||||
TShortwayPoint *pTVar3;
|
|
||||||
int iVar4;
|
|
||||||
|
|
||||||
iVar4 = (xmax - xmin) + 1;
|
|
||||||
iVar1 = (ymax - ymin) + 1;
|
|
||||||
this->xmin = xmin;
|
|
||||||
this->ymin = ymin;
|
|
||||||
this->dx = iVar4;
|
|
||||||
this->dy = iVar1;
|
|
||||||
if ((iVar4 < 1) || (iVar1 < 1)) {
|
|
||||||
error("matrix: Ungueltige Feldgroesse %d..%d, %d..%d.\n",xmin,xmax,ymin,ymax);
|
|
||||||
iVar4 = this->dx;
|
|
||||||
if (iVar4 < 1) {
|
|
||||||
this->dx = 1;
|
|
||||||
iVar4 = 1;
|
|
||||||
}
|
|
||||||
iVar1 = this->dy;
|
|
||||||
if (iVar1 < 1) {
|
|
||||||
this->dy = 1;
|
|
||||||
iVar1 = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iVar4 = iVar4 * iVar1;
|
|
||||||
pTVar2 = (TShortwayPoint *)operator_new__(iVar4 * 0x1c);
|
|
||||||
pTVar3 = pTVar2;
|
|
||||||
while (iVar4 = iVar4 + -1, iVar4 != -1) {
|
|
||||||
pTVar3->Waylength = -1;
|
|
||||||
pTVar3->Heuristic = -1;
|
|
||||||
pTVar3->Predecessor = (TShortwayPoint *)0x0;
|
|
||||||
pTVar3->NextToExpand = (TShortwayPoint *)0x0;
|
|
||||||
pTVar3 = pTVar3 + 1;
|
|
||||||
}
|
|
||||||
this->entry = pTVar2;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void __static_initialization_and_destruction_0(int __initialize_p,int __priority)
|
void __static_initialization_and_destruction_0(int __initialize_p,int __priority)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@ -515,14 +515,6 @@ struct THouse {
|
|||||||
int Help;
|
int Help;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct matrix<long_unsigned_int> { // Original name: matrix<long unsigned int>
|
|
||||||
int xmin;
|
|
||||||
int ymin;
|
|
||||||
int dx;
|
|
||||||
int dy;
|
|
||||||
ulong *entry;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TWaitinglistEntry {
|
struct TWaitinglistEntry {
|
||||||
struct TWaitinglistEntry *Next;
|
struct TWaitinglistEntry *Next;
|
||||||
char Name[30];
|
char Name[30];
|
||||||
@ -698,14 +690,6 @@ struct TShortwayPoint {
|
|||||||
struct TShortwayPoint *NextToExpand;
|
struct TShortwayPoint *NextToExpand;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct matrix<TShortwayPoint> {
|
|
||||||
int xmin;
|
|
||||||
int ymin;
|
|
||||||
int dx;
|
|
||||||
int dy;
|
|
||||||
struct TShortwayPoint *entry;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TCronEntry {
|
struct TCronEntry {
|
||||||
struct Object Obj;
|
struct Object Obj;
|
||||||
ulong RoundNr;
|
ulong RoundNr;
|
||||||
@ -766,16 +750,6 @@ struct TCondition {
|
|||||||
int Number;
|
int Number;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct matrix3d<TSector*> {
|
|
||||||
int xmin;
|
|
||||||
int ymin;
|
|
||||||
int zmin;
|
|
||||||
int dx;
|
|
||||||
int dy;
|
|
||||||
int dz;
|
|
||||||
struct TSector **entry;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TSector {
|
struct TSector {
|
||||||
struct Object MapCon[32][32];
|
struct Object MapCon[32][32];
|
||||||
ulong TimeStamp;
|
ulong TimeStamp;
|
||||||
@ -798,14 +772,6 @@ struct THelpDepot {
|
|||||||
int DepotNr;
|
int DepotNr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct matrix<int> {
|
|
||||||
int xmin;
|
|
||||||
int ymin;
|
|
||||||
int dx;
|
|
||||||
int dy;
|
|
||||||
int *entry;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct listIterator<storeunit<TPlayerIndexLeafNode,_100>_> { // Original name: listIterator<storeunit<TPlayerIndexLeafNode, 100> >
|
struct listIterator<storeunit<TPlayerIndexLeafNode,_100>_> { // Original name: listIterator<storeunit<TPlayerIndexLeafNode, 100> >
|
||||||
struct listnode<storeunit<TPlayerIndexLeafNode,_100>_> *actNode;
|
struct listnode<storeunit<TPlayerIndexLeafNode,_100>_> *actNode;
|
||||||
};
|
};
|
||||||
|
|||||||
132
src/containers/matrix.hh
Normal file
132
src/containers/matrix.hh
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
#ifndef TIBIA_MATRIX_HH_
|
||||||
|
#define TIBIA_MATRIX_HH_ 1
|
||||||
|
|
||||||
|
typedef<typename T>
|
||||||
|
struct matrix{
|
||||||
|
// REGULAR FUNCTIONS
|
||||||
|
// =========================================================================
|
||||||
|
matrix(int xmin, int xmax, int ymin, int ymax){
|
||||||
|
int dx = (xmax - xmin) + 1;
|
||||||
|
int dy = (ymax - ymin) + 1;
|
||||||
|
|
||||||
|
if(dx < 1 || dy < 1){
|
||||||
|
error("matrix: Ungueltige Feldgroesse %d..%d, %d..%d.\n", xmin, xmax, ymin, ymax);
|
||||||
|
|
||||||
|
if(dx < 1){
|
||||||
|
dx = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dy < 1){
|
||||||
|
dy = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->xmin = xmin;
|
||||||
|
this->ymin = ymin;
|
||||||
|
this->dx = dx;
|
||||||
|
this->dy = dy;
|
||||||
|
this->entry = new T[dx * dy];
|
||||||
|
}
|
||||||
|
|
||||||
|
matrix(int xmin, int xmax, int ymin, int ymax, T init) : matrix(xmin, xmax, ymin, ymax) {
|
||||||
|
int count = this->dx * this->dy;
|
||||||
|
for(int i = 0; i < count; i += 1){
|
||||||
|
this->entry[i] = init;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(fusion): Probably missing some inlined destructor?
|
||||||
|
|
||||||
|
T *at(int x, int y){
|
||||||
|
int xoffset = x - this->xmin;
|
||||||
|
int yoffset = y - this->ymin;
|
||||||
|
if(xoffset < 0 || xoffset >= this->dx || yoffset < 0 || yoffset >= this->dy){
|
||||||
|
error("matrix::operator(): Ungueltiger Index %d/%d.\n", x, y);
|
||||||
|
return &this->entry[0];
|
||||||
|
}else{
|
||||||
|
// TODO(fusion): Are we really storing this in row major order?
|
||||||
|
return &this->entry[yoffset * this->dx + xoffset];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DATA
|
||||||
|
// =========================================================================
|
||||||
|
int xmin;
|
||||||
|
int ymin;
|
||||||
|
int dx;
|
||||||
|
int dy;
|
||||||
|
T *entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef<typename T>
|
||||||
|
struct matrix3d{
|
||||||
|
// REGULAR FUNCTIONS
|
||||||
|
// =========================================================================
|
||||||
|
matrix3d(int xmin, int xmax, int ymin, int ymax, int zmin, int zmax){
|
||||||
|
int dx = (xmax - xmin) + 1;
|
||||||
|
int dy = (ymax - ymin) + 1;
|
||||||
|
int dz = (zmax - zmin) + 1;
|
||||||
|
|
||||||
|
if(dx < 1 || dy < 1 || dz < 1){
|
||||||
|
error("matrix3d: Ungueltige Feldgroesse %d..%d, %d..%d, %d..%d.\n",
|
||||||
|
xmin, xmax, ymin, ymax, zmin, zmax);
|
||||||
|
|
||||||
|
if(dx < 1){
|
||||||
|
dx = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dy < 1){
|
||||||
|
dy = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dz < 1){
|
||||||
|
dz = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->xmin = xmin;
|
||||||
|
this->ymin = ymin;
|
||||||
|
this->dx = dx;
|
||||||
|
this->dy = dy;
|
||||||
|
this->entry = new T[dx * dy];
|
||||||
|
}
|
||||||
|
|
||||||
|
matrix3d(int xmin, int xmax, int ymin, int ymax, int zmin, int zmax, T init)
|
||||||
|
: matrix(xmin, xmax, ymin, ymax, zmin, zmax) {
|
||||||
|
int count = this->dx * this->dy * this->dz;
|
||||||
|
for(int i = 0; i < count; i += 1){
|
||||||
|
this->entry[i] = init;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(fusion): Probably missing some inlined destructor?
|
||||||
|
|
||||||
|
T *at(int x, int y, int z){
|
||||||
|
int xoffset = x - this->xmin;
|
||||||
|
int yoffset = y - this->ymin;
|
||||||
|
int zoffset = z - this->zmin;
|
||||||
|
if(xoffset < 0 || xoffset >= this->dx
|
||||||
|
|| yoffset < 0 || yoffset >= this->dy
|
||||||
|
|| zoffset < 0 || zoffset >= this->dz){
|
||||||
|
error("matrix3d::operator(): Ungueltiger Index %d/%d/%d.\n", x, y, z);
|
||||||
|
return &this->entry[0];
|
||||||
|
}else{
|
||||||
|
// TODO(fusion): Same as `matrix::at` on the XY plane.
|
||||||
|
return &this->entry[zoffset * this->dx * this->dy
|
||||||
|
+ yoffset * this->dx
|
||||||
|
+ xoffset];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DATA
|
||||||
|
// =========================================================================
|
||||||
|
int xmin;
|
||||||
|
int ymin;
|
||||||
|
int zmin;
|
||||||
|
int dx;
|
||||||
|
int dy;
|
||||||
|
int dz;
|
||||||
|
T *entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //TIBIA_MATRIX_HH_
|
||||||
Loading…
x
Reference in New Issue
Block a user