Skip to content

Commit

Permalink
Switch to a VectorClass
Browse files Browse the repository at this point in the history
  • Loading branch information
ZivDero committed Sep 10, 2024
1 parent 47b3d5d commit f7e4b7c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/extensions/house/houseext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ HouseClassExtension::HouseClassExtension(const HouseClass *this_ptr) :

for (int i = 0; i < Tiberiums.Count(); i++)
{
TiberiumStorage.Add(0);
WeedStorage.Add(0);
TiberiumStorage[i] = 0;
WeedStorage[i] = 0;
}

if (this_ptr)
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/house/houseext.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ HouseClassExtension final : public AbstractClassExtension
/**
* Replacement Tiberium storage.
*/
DynamicVectorClass<int> TiberiumStorage;
VectorClass<int> TiberiumStorage;

/**
* Replacement Weed storage.
*/
DynamicVectorClass<int> WeedStorage;
VectorClass<int> WeedStorage;
};
6 changes: 3 additions & 3 deletions src/extensions/storage/storageext.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
class StorageClassExt
{
public:
StorageClassExt(DynamicVectorClass<int>* vector) :
StorageClassExt(VectorClass<int>* vector) :
Types(vector)
{
}

public:
/**
* Pointer to the DVC located in the extension for the class that contains the StorageClass.
* Pointer to the vector located in the extension for the class that contains the StorageClass.
*/
DynamicVectorClass<int>* Types;
VectorClass<int>* Types;

public:
int Get_Total_Value() const;
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/techno/technoext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ TechnoClassExtension::TechnoClassExtension(const TechnoClass *this_ptr) :

for (int i = 0; i < Tiberiums.Count(); i++)
{
Storage.Add(0);
Storage[i] = 0;
}

if (this_ptr)
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/techno/technoext.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ class TechnoClassExtension : public RadioClassExtension
/**
* Replacement Tiberium storage.
*/
DynamicVectorClass<int> Storage;
VectorClass<int> Storage;
};
10 changes: 5 additions & 5 deletions src/vinifera/vinifera_saveload.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ void Vinifera_Remap_Storage_Pointers();


template<class T>
HRESULT Save_Primitive_Vector(LPSTREAM& pStm, DynamicVectorClass<T>& list)
HRESULT Save_Primitive_Vector(LPSTREAM& pStm, VectorClass<T>& list)
{
int count = list.Count();
int count = list.Length();
HRESULT hr = pStm->Write(&count, sizeof(count), nullptr);
if (FAILED(hr)) {
return hr;
Expand All @@ -122,15 +122,15 @@ HRESULT Save_Primitive_Vector(LPSTREAM& pStm, DynamicVectorClass<T>& list)


template<class T>
HRESULT Load_Primitive_Vector(LPSTREAM& pStm, DynamicVectorClass<T>& list)
HRESULT Load_Primitive_Vector(LPSTREAM& pStm, VectorClass<T>& list)
{
int count = 0;
HRESULT hr = pStm->Read(&count, sizeof(count), nullptr);
if (FAILED(hr)) {
return hr;
}

new (&list) DynamicVectorClass<T>();
new (&list) VectorClass<T>(count);

if (count <= 0) {
return hr;
Expand All @@ -143,7 +143,7 @@ HRESULT Load_Primitive_Vector(LPSTREAM& pStm, DynamicVectorClass<T>& list)
if (FAILED(hr)) {
return hr;
}
list.Add(obj);
list[index] = obj;

}

Expand Down

0 comments on commit f7e4b7c

Please sign in to comment.