Skip to content

Commit 329a958

Browse files
committed
Merge branch 'main' of https://github.com/TheSuperHackers/GeneralsGameCode into weekly-release
2 parents a801bfb + db0730f commit 329a958

File tree

392 files changed

+3274
-2900
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

392 files changed

+3274
-2900
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ if (IS_VS6_BUILD)
6363
# If there is a desire to make this work, then a fixed max sdk needs to be created.
6464
add_subdirectory(Dependencies/MaxSDK)
6565
endif()
66-
add_subdirectory(Dependencies/SafeDisc)
6766
add_subdirectory(Dependencies/Utility)
6867
add_subdirectory(resources)
6968

Core/GameEngine/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ set(GAMEENGINE_SRC
2121
# Include/Common/CDManager.h
2222
# Include/Common/ClientUpdateModule.h
2323
# Include/Common/CommandLine.h
24-
# Include/Common/CopyProtection.h
2524
# Include/Common/crc.h
2625
# Include/Common/CRCDebug.h
2726
# Include/Common/CriticalSection.h
@@ -43,6 +42,7 @@ set(GAMEENGINE_SRC
4342
# Include/Common/FunctionLexicon.h
4443
# Include/Common/GameAudio.h
4544
# Include/Common/GameCommon.h
45+
Include/Common/GameDefines.h
4646
# Include/Common/GameEngine.h
4747
# Include/Common/GameLOD.h
4848
# Include/Common/GameMemory.h
@@ -631,7 +631,6 @@ set(GAMEENGINE_SRC
631631
# Source/Common/System/AsciiString.cpp
632632
# Source/Common/System/BuildAssistant.cpp
633633
# Source/Common/System/CDManager.cpp
634-
# Source/Common/System/CopyProtection.cpp
635634
# Source/Common/System/CriticalSection.cpp
636635
# Source/Common/System/DataChunk.cpp
637636
# Source/Common/System/Debug.cpp
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
** Command & Conquer Generals Zero Hour(tm)
3+
** Copyright 2025 TheSuperHackers
4+
**
5+
** This program is free software: you can redistribute it and/or modify
6+
** it under the terms of the GNU General Public License as published by
7+
** the Free Software Foundation, either version 3 of the License, or
8+
** (at your option) any later version.
9+
**
10+
** This program is distributed in the hope that it will be useful,
11+
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
** GNU General Public License for more details.
14+
**
15+
** You should have received a copy of the GNU General Public License
16+
** along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#pragma once
20+
21+
// Note: Retail compatibility must not be broken before this project officially does.
22+
// Use RETAIL_COMPATIBLE_CRC and RETAIL_COMPATIBLE_XFER_SAVE to guard breaking changes.
23+
24+
#ifndef RETAIL_COMPATIBLE_CRC
25+
#define RETAIL_COMPATIBLE_CRC (1) // Game is expected to be CRC compatible with retail Generals 1.08, Zero Hour 1.04
26+
#endif
27+
28+
#ifndef RETAIL_COMPATIBLE_XFER_SAVE
29+
#define RETAIL_COMPATIBLE_XFER_SAVE (1) // Game is expected to be Xfer Save compatible with retail Generals 1.08, Zero Hour 1.04
30+
#endif
31+
32+
#ifndef ENABLE_GAMETEXT_SUBSTITUTES
33+
#define ENABLE_GAMETEXT_SUBSTITUTES (1) // The code can provide substitute texts when labels and strings are missing in the STR or CSF translation file
34+
#endif

Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ Is_In_Param_List
228228
// OutputDebugString( "\n" );
229229

230230
// if ( stricmp( string.Peek_Buffer(), param_to_check ) == 0 ) // Breaks with whitespaces
231-
if ( strstr( string.Peek_Buffer(), param_to_check ) != 0 )
231+
if ( strstr( string.str(), param_to_check ) != 0 )
232232
{
233233
return( true );
234234
}
@@ -447,7 +447,7 @@ AnimatedSoundMgrClass::Get_Embedded_Sound_Name (HAnimClass *anim)
447447
return NULL;
448448
}
449449

450-
return list->BoneName.Peek_Buffer();
450+
return list->BoneName.str();
451451
}
452452

453453

@@ -527,7 +527,7 @@ AnimatedSoundMgrClass::Trigger_Sound
527527
//
528528
// Stop the audio
529529
//
530-
SoundLibrary->Stop_Playing_Audio( sound_list->List[index]->SoundName.Peek_Buffer() );
530+
SoundLibrary->Stop_Playing_Audio( sound_list->List[index]->SoundName.str() );
531531
}
532532
else
533533
{
@@ -536,11 +536,11 @@ AnimatedSoundMgrClass::Trigger_Sound
536536
//
537537
if (sound_list->List[index]->Is2D == true)
538538
{
539-
SoundLibrary->Play_2D_Audio(sound_list->List[index]->SoundName.Peek_Buffer());
539+
SoundLibrary->Play_2D_Audio(sound_list->List[index]->SoundName.str());
540540
}
541541
else
542542
{
543-
SoundLibrary->Play_3D_Audio(sound_list->List[index]->SoundName.Peek_Buffer(), tm);
543+
SoundLibrary->Play_3D_Audio(sound_list->List[index]->SoundName.str(), tm);
544544
}
545545
}
546546

Core/Libraries/Source/WWVegas/WW3D2/rendobj.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,9 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL
452452
virtual void Scale(float scale) { };
453453
virtual void Scale(float scalex, float scaley, float scalez) { };
454454
virtual void Set_ObjectScale(float scale) { ObjectScale=scale;} //set's a scale factor that's factored into transform matrix. {ScaleFactor=scale; };
455-
const float Get_ObjectScale( void ) const { return ObjectScale; };
455+
float Get_ObjectScale( void ) const { return ObjectScale; };
456456
void Set_ObjectColor(unsigned int color) { ObjectColor=color;} //the color that was used to modify the asset for player team color (for Generals). -MW
457-
const unsigned int Get_ObjectColor( void ) const { return ObjectColor; };
457+
unsigned int Get_ObjectColor( void ) const { return ObjectColor; };
458458

459459
virtual int Get_Sort_Level(void) const { return 0; /* SORT_LEVEL_NONE */ }
460460
virtual void Set_Sort_Level(int level) { }

Core/Libraries/Source/WWVegas/WW3D2/statistics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static void Record_Texture_End()
113113
// if (tfc->Get_Texture_Flash()) flash="F";
114114
// }
115115

116-
working_string.Format("%4.4d %3.3d %3.3d %s ",id,texture_statistics[a].usage_count,texture_statistics[a].change_count,flash.Peek_Buffer());
116+
working_string.Format("%4.4d %3.3d %3.3d %s ",id,texture_statistics[a].usage_count,texture_statistics[a].change_count,flash.str());
117117
texture_statistics_string+=working_string;
118118

119119
StringClass error="";

Core/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ bool W3DExclusionListClass::Is_Excluded(HAnimClass * hanim) const
8686
{
8787
// For HAnims, the name to check is the one trailing the '.'
8888
StringClass copy = hanim->Get_Name();
89-
char * root_name = copy.Peek_Buffer();
89+
const char * root_name = copy.str();
9090

91-
char * tmp = strchr(root_name,'.');
91+
const char * tmp = strchr(root_name,'.');
9292
if (tmp) {
9393
return Is_Excluded(tmp + 1);
9494
} else {

Core/Libraries/Source/WWVegas/WWAudio/WWAudio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ class WWAudioClass
386386
// Note: The cache sizes are in kilo-bytes. The default
387387
// is currently set to 1MB.
388388
//
389-
bool Set_Cache_Size (int kbytes = DEF_CACHE_SIZE) { m_MaxCacheSize = (kbytes * 1024); }
389+
void Set_Cache_Size (int kbytes = DEF_CACHE_SIZE) { m_MaxCacheSize = (kbytes * 1024); }
390390
int Get_Cache_Size (void) const { return m_MaxCacheSize / 1024; }
391391
int Get_Current_Cache_Size (void) const { return m_CurrentCacheSize; }
392392

Core/Libraries/Source/WWVegas/WWDebug/wwprofile.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void WWProfileHierachyNodeClass::Write_To_File(FileClass* file,int recursion)
202202
for (i=0;i<recursion;++i) { string+="\t"; }
203203
work.Format("%s\t%d\t%f\r\n",Name,TotalCalls,TotalTime*1000.0f);
204204
string+=work;
205-
file->Write(string.Peek_Buffer(),string.Get_Length());
205+
file->Write(string.str(),string.Get_Length());
206206
}
207207
if (Child) {
208208
Child->Write_To_File(file,recursion+1);
@@ -577,7 +577,7 @@ void WWProfileManager::End_Collecting(const char* filename)
577577
"Total frames: %d, average frame time: %fms\r\n"
578578
"All frames taking more than twice the average frame time are marked with keyword SPIKE.\r\n\r\n",
579579
ProfileCollectVector.Count(),avg_frame_time*1000.0f);
580-
file->Write(str.Peek_Buffer(),str.Get_Length());
580+
file->Write(str.str(),str.Get_Length());
581581

582582
HashTemplateIterator<StringClass,unsigned> ite(ProfileStringHash);
583583
for (ite.First();!ite.Is_Done();ite.Next()) {
@@ -591,18 +591,18 @@ void WWProfileManager::End_Collecting(const char* filename)
591591
if (name[i]==';') name[i]=':';
592592
}
593593
str.Format("ID: %d %s\r\n",ite.Peek_Value(),name);
594-
file->Write(str.Peek_Buffer(),str.Get_Length());
594+
file->Write(str.str(),str.Get_Length());
595595
}
596596

597597
str.Format("\r\n\r\n");
598-
file->Write(str.Peek_Buffer(),str.Get_Length());
598+
file->Write(str.str(),str.Get_Length());
599599

600600
for (i=0;i<ProfileCollectVector.Count();++i) {
601601
float frame_time=ProfileCollectVector[i]->Get_Total_Time();
602602
str.Format("FRAME: %d %2.2f %s ",i,frame_time*1000.0f,frame_time>avg_frame_time*2.0f ? "SPIKE" : "OK");
603603
ProfileCollectVector[i]->Add_To_String_Compact(str,0);
604604
str+="\r\n";
605-
file->Write(str.Peek_Buffer(),str.Get_Length());
605+
file->Write(str.str(),str.Get_Length());
606606
}
607607

608608
//

Core/Libraries/Source/WWVegas/WWLib/always.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
#include <Utility/compat.h>
4848
#include <Utility/stdint_adapter.h>
4949

50+
#include <Utility/CppMacros.h>
51+
5052
// Disable warning about exception handling not being enabled. It's used as part of STL - in a part of STL we don't use.
5153
#pragma warning(disable : 4530)
5254

Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ void CPUDetectClass::Init_Processor_String()
792792
case INTEL_PROCESSOR_PENTIUM4: str+="Pentium4"; break;
793793
}
794794
}
795-
strncpy(ProcessorString,str.Peek_Buffer(),sizeof(ProcessorString));
795+
strncpy(ProcessorString,str.str(),sizeof(ProcessorString));
796796
}
797797

798798
}
@@ -959,7 +959,7 @@ void CPUDetectClass::Init_Processor_Log()
959959
#ifdef WIN32
960960
SYSLOG(("OS-Info: %s\r\n", OSVersionExtraInfo));
961961
#elif defined(_UNIX)
962-
SYSLOG(("OS-Info: %s\r\n", OSVersionExtraInfo.Peek_Buffer()));
962+
SYSLOG(("OS-Info: %s\r\n", OSVersionExtraInfo.str()));
963963
#endif
964964

965965
SYSLOG(("Processor: %s\r\n",CPUDetectClass::Get_Processor_String()));
@@ -974,7 +974,7 @@ void CPUDetectClass::Init_Processor_Log()
974974
#ifdef WIN32
975975
SYSLOG(("Processor type: %s\r\n", cpu_type));
976976
#elif defined(_UNIX)
977-
SYSLOG(("Processor type: %s\r\n", cpu_type.Peek_Buffer()));
977+
SYSLOG(("Processor type: %s\r\n", cpu_type.str()));
978978
#endif
979979

980980
SYSLOG(("\r\n"));

Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ FileClass * SimpleFileFactoryClass::Get_File( char const *filename )
285285
const char *tok;
286286
while((tok=strtok(tokstart, ";")) != NULL) {
287287
tokstart=NULL;
288-
new_name.Format("%s%s",tok,stripped_name.Peek_Buffer());
288+
new_name.Format("%s%s",tok,stripped_name.str());
289289
file->Set_Name( new_name ); // Call Set_Name to force an allocated name
290290
if (file->Open()) {
291291
file->Close();

Core/Libraries/Source/WWVegas/WWLib/hashtemplate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ template <class KeyType, class ValueType> inline HashTemplateClass<KeyType,Value
415415
template <> inline unsigned int HashTemplateKeyClass<StringClass>::Get_Hash_Value(const StringClass& s)
416416
{
417417
unsigned int len=s.Get_Length();
418-
unsigned char* buffer=(unsigned char*)s.Peek_Buffer();
418+
unsigned const char* buffer=(unsigned const char*)s.str();
419419
if (len<8) {
420420
unsigned int hval=0;
421421
for (unsigned int a=0;a<len;++a) {

Core/Libraries/Source/WWVegas/WWLib/ref_ptr.h

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@
138138
copying.
139139
140140
To create a RefCountPtr<T> from a raw pointer, use the global template functions
141-
Create_NEW should be used when wrapping a pointer that has just been created with NEW
142-
Create_Get should be used when wrapping a pointer that has been returned from a "Get" function
141+
Create_NoAddRef should be used when wrapping a pointer that has just been created with NEW
142+
Create_NoAddRef should be used when wrapping a pointer that has been returned from a "Get" function
143143
(the function added a reference prior to returning the pointer)
144-
Create_Peek should be used when wrapping a pointer that has been returned from a "Peek" function
144+
Create_AddRef should be used when wrapping a pointer that has been returned from a "Peek" function
145145
(the function did not add a reference prior to returning the pointer).
146146
147-
Create_Get and Create_Peek are provided to allow old code to migrate from manual reference count
147+
Create_NoAddRef and Create_AddRef are provided to allow old code to migrate from manual reference count
148148
management to RefCountPtr. New code written with RefCountPtr should rarely if ever use
149-
Create_Get and Create_Peek.
149+
Create_NoAddRef and Create_AddRef.
150150
151151
If it is absolutely necessary to extract the raw pointer, use Peek. Peek does not add a new
152152
reference to the object. Using a Peek'd object after its RefCountPtr has gone out of scope requires
@@ -158,7 +158,7 @@
158158
159159
Automatic construction of a RefCountPtr from a raw pointer is enabled if
160160
ALLOW_AUTOMATIC_REF_COUNT_PTR_CONSTRUCTION is defined.
161-
This may be useful when migrating existing code to use RefCountPtr, but is completely safe,
161+
This may be useful when migrating existing code to use RefCountPtr, but is not completely safe,
162162
since it is not possible to determine if the pointer is being Get'd or Peek'd.
163163
Please note that the constructor WILL add a reference to the object, which errs on the side
164164
of leaking references rather than prematurely deleting objects. Whenever possible, use the
@@ -216,23 +216,25 @@
216216
};
217217
*/
218218

219+
219220
class DummyPtrType;
220221

221222
template <class T>
222223
class RefCountPtr
223224
{
224225
public:
225-
friend RefCountPtr<T> Create_NEW(T *t)
226-
{
227-
return RefCountPtr<T>(t, RefCountPtr<T>::GET);
228-
}
229226

230-
friend RefCountPtr<T> Create_Get(T *t)
227+
// Creates a RefCountPtr<T> and does not increment the reference counter of the passed object.
228+
// Is generally used for objects returned by operator new and "Get" functions.
229+
static RefCountPtr<T> Create_NoAddRef(T *t)
231230
{
231+
WWASSERT(t == NULL || t->Num_Refs() >= 1);
232232
return RefCountPtr<T>(t, RefCountPtr<T>::GET);
233233
}
234234

235-
friend RefCountPtr<T> Create_Peek(T *t)
235+
// Creates a RefCountPtr<T> and increments the reference counter of the passed object.
236+
// Is generally used for objects returned by "Peek" functions.
237+
static RefCountPtr<T> Create_AddRef(T *t)
236238
{
237239
return RefCountPtr<T>(t, RefCountPtr<T>::PEEK);
238240
}
@@ -371,20 +373,28 @@ class RefCountPtr
371373

372374
T & operator *(void) const
373375
{
374-
G_ASSERT(0 != Referent);
376+
WWASSERT(0 != Referent);
375377
return *Referent;
376378
}
377379

378-
// Note : This should typiccally only be used when mixing code that uses RefCountPtr and
380+
// Note : This should typically only be used when mixing code that uses RefCountPtr and
379381
// manually managed ref counts on raw points.
380-
// Code that consistently uses RefCountPtr should never get ahold of a raw T*
382+
// Code that consistently uses RefCountPtr should never get a hold of a raw T*
381383
T * Peek(void) const
382384
{
383385
return Referent;
384386
}
385387

388+
// Releases the held pointer without changing its reference counter.
389+
T * Release(void)
390+
{
391+
T * p = Referent;
392+
Referent = 0;
393+
return p;
394+
}
395+
386396
private:
387-
enum ReferenceHandling { GET, PEEK};
397+
enum ReferenceHandling { GET, PEEK };
388398

389399
RefCountPtr(T * referent, ReferenceHandling reference_handling)
390400
: Referent(referent)
@@ -416,7 +426,8 @@ bool operator <(const RefCountPtr<LHS> & lhs, const RefCountPtr<RHS> & rhs)
416426
template <class RHS>
417427
bool operator ==(DummyPtrType * dummy, const RefCountPtr<RHS> & rhs)
418428
{
419-
FAIL_IF(0 != dummy) {
429+
if (0 != dummy) {
430+
WWASSERT(0);
420431
return false;
421432
}
422433

@@ -428,7 +439,8 @@ bool operator ==(DummyPtrType * dummy, const RefCountPtr<RHS> & rhs)
428439
template <class RHS>
429440
bool operator !=(DummyPtrType * dummy, const RefCountPtr<RHS> & rhs)
430441
{
431-
FAIL_IF(0 != dummy) {
442+
if (0 != dummy) {
443+
WWASSERT(0);
432444
return true;
433445
}
434446

@@ -438,7 +450,7 @@ bool operator !=(DummyPtrType * dummy, const RefCountPtr<RHS> & rhs)
438450
template <class Derived, class Base>
439451
RefCountPtr<Derived> Static_Cast(const RefCountPtr<Base> & base)
440452
{
441-
return Create_Peek((Derived *)base.Peek());
453+
return RefCountPtr<Derived>::Create_AddRef((Derived *)base.Peek());
442454
}
443455

444456
#endif

Core/Libraries/Source/WWVegas/WWLib/refcount.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
#include "LISTNODE.H"
4949
#endif
5050

51+
#include "wwdebug.h"
52+
5153
class RefCountClass;
5254

5355

@@ -148,7 +150,7 @@ class RefCountClass
148150
Dec_Total_Refs(this);
149151
#endif
150152
NumRefs--;
151-
assert(NumRefs >= 0);
153+
WWASSERT(NumRefs >= 0);
152154
if (NumRefs == 0) const_cast<RefCountClass*>(this)->Delete_This();
153155
}
154156

@@ -182,7 +184,7 @@ class RefCountClass
182184
#ifndef NDEBUG
183185
Remove_Active_Ref(this);
184186
#endif
185-
assert(NumRefs == 0);
187+
WWASSERT(NumRefs == 0);
186188
}
187189

188190
private:

0 commit comments

Comments
 (0)