Skip to content

Commit

Permalink
Merge branch 'vanilla' into PR-31
Browse files Browse the repository at this point in the history
  • Loading branch information
giulianobelinassi authored May 21, 2024
2 parents 9961a23 + 5071cd6 commit 27e9a7b
Show file tree
Hide file tree
Showing 22 changed files with 125 additions and 79 deletions.
13 changes: 3 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,9 @@ if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Windows")
option(WIN9X "Enable support for Windows 95/98/ME." OFF)
option(DSOUND "Enable DirectSound audio. (deprecated)" OFF)
option(DDRAW "Enable DirectDraw video backend. (deprecated)" OFF)
option(SDL1 "Enable SDL1 video backend." OFF)
option(SDL2 "Enable SDL2 video backend." ON)
option(OPENAL "Enable OpenAL audio backend." ON)
add_feature_info(Windows9x WIN9X "Windows 95/98/ME support" OFF)
add_feature_info(DirectSound DSOUND "DirectSound audio backend (deprecated)")
add_feature_info(DirectDraw DDRAW "DirectDraw video backend (deprecated)")
add_feature_info(SDL1 SDL1 "SDL1 video backend")
add_feature_info(SDL2 SDL2 "SDL2 video backend")
add_feature_info(OpenAL OPENAL "OpenAL audio backend")
else()
add_feature_info(SDL1 SDL1 "SDL1 video backend")
add_feature_info(SDL2 SDL2 "SDL2 video backend")
set(OPENAL TRUE)
endif()

if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
Expand All @@ -56,6 +46,9 @@ if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
endif()
endif()

add_feature_info(SDL1 SDL1 "SDL1 video backend")
add_feature_info(SDL2 SDL2 "SDL2 video backend")
add_feature_info(OpenAL OPENAL "OpenAL audio backend")
add_feature_info(RemasterTD BUILD_REMASTERTD, "Remastered Tiberian Dawn dll")
add_feature_info(RemasterRA BUILD_REMASTERRA "Remastered Red Alert dll")
add_feature_info(VanillaTD BUILD_VANILLATD "Tiberian Dawn executable")
Expand Down
3 changes: 2 additions & 1 deletion common/base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#include "base64.h"
#include <stddef.h>
#include "endianness.h"

/*
** This is the magic padding character used to fill out the encoded data to a multiple of
Expand Down Expand Up @@ -425,4 +426,4 @@ implementations.
within base64-encoded parts of multipart entities because no hyphen
characters are used in the base64 encoding.
*/
*/
17 changes: 6 additions & 11 deletions common/connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

#include <stdio.h>
//#include <mem.h>
#include <sys/timeb.h>
#include <chrono>
#include <string.h>
#include "connect.h"

Expand Down Expand Up @@ -747,7 +747,6 @@ int ConnectionClass::Service_Receive_Queue(void)
*=========================================================================*/
unsigned int ConnectionClass::Time(void)
{
static struct timeb mytime; // DOS time
unsigned int msec;

#ifdef WWLIB32_H
Expand All @@ -764,23 +763,19 @@ unsigned int ConnectionClass::Time(void)
/*------------------------------------------------------------------------
Otherwise, use the DOS timer
------------------------------------------------------------------------*/
else {
ftime(&mytime);
msec = (unsigned int)mytime.time * 1000 + (unsigned int)mytime.millitm;
return ((msec / 100) * 6);
}

#else

/*------------------------------------------------------------------------
If the Westwood library isn't being used, use the DOS timer.
------------------------------------------------------------------------*/
ftime(&mytime);
msec = (unsigned int)mytime.time * 1000 + (unsigned int)mytime.millitm;
return ((msec / 100) * 6);

#endif

static auto epoch = std::chrono::steady_clock::now().time_since_epoch();
auto now = std::chrono::steady_clock::now().time_since_epoch();
msec = unsigned(std::chrono::duration_cast<std::chrono::milliseconds>(now - epoch).count());

return ((msec / 100) * 6);
} /* end of Time */

/***************************************************************************
Expand Down
3 changes: 3 additions & 0 deletions common/file_posix.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "file.h"

#include <string.h>
Expand Down
19 changes: 19 additions & 0 deletions common/graphicsviewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,3 +980,22 @@ void GraphicViewPortClass::Draw_Rect(int x1_pixel, int y1_pixel, int x2_pixel, i
Draw_Line(x2_pixel, y1_pixel, x2_pixel, y2_pixel, color);
Unlock();
}

void GraphicViewPortClass::Texture_Fill_Rect(int xpos,
int ypos,
int width,
int height,
unsigned char* shape_pointer,
int source_width,
int source_height)
{
if (Lock()) {
for (int y = ypos; y < ypos + height; y++) {
for (int x = xpos; x < xpos + width; x++) {
LogicPage->Put_Pixel(
x, y, *(shape_pointer + ((y % source_height) * source_width) + (x % source_width)));
}
}
Unlock();
}
}
11 changes: 2 additions & 9 deletions common/graphicsviewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,20 +289,13 @@ class GraphicViewPortClass
void Remap(int sx, int sy, int width, int height, void* remap);
void Remap(void* remap);
void Draw_Stamp(void const* icondata, int icon, int x_pixel, int y_pixel, void const* remap, int clip_window);

// PG_TO_FIX
// This seems to be missing. Might not be needed anyway since it looks like it's only used for UI drawing. ST -
// 12/17/2018 6:11PM
void Texture_Fill_Rect(int xpos,
int ypos,
int width,
int height,
void const* shape_pointer,
unsigned char* shape_pointer,
int source_width,
int source_height)
{
return;
}
int source_height);

// This doesnt seem to exist anywhere?? - Steve T 9/26/95 6:05PM
// VOID Grey_Out_Region(int x, int y, int width, int height, int color);
Expand Down
9 changes: 8 additions & 1 deletion common/mp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ void XMP_DER_Decode(digit* result, unsigned char const* input, int precision)
}
}

#ifndef __BIG_ENDIAN__
// FIXME: does not for work big-endian
/***********************************************************************************************
* XMP_Encode -- Encode MP number into buffer. *
* *
Expand Down Expand Up @@ -308,6 +310,7 @@ unsigned XMP_Encode(unsigned char* to, unsigned tobytes, digit const* from, int

return (tobytes);
}
#endif

/***********************************************************************************************
* XMP_Encode -- Encode MP number into buffer as compactly as possible. *
Expand Down Expand Up @@ -358,7 +361,8 @@ unsigned XMP_Encode(unsigned char* to, digit const* from, int precision)
unsigned char* number_ptr;

unsigned char* const end = (unsigned char*)from;
for (number_ptr = (unsigned char*)end + precision - 1; number_ptr > (unsigned char*)end; number_ptr--) {
for (number_ptr = (unsigned char*)end + precision * sizeof(digit) - 1; number_ptr > (unsigned char*)end;
number_ptr--) {
if (*number_ptr != filler)
break;
}
Expand Down Expand Up @@ -922,6 +926,8 @@ unsigned XMP_Count_Bits(const digit* number, int precision)
return (total_bit_count);
}

#ifndef __BIG_ENDIAN__
// FIXME: does not work for big-endian
/***********************************************************************************************
* XMP_Count_Bytes -- Counts the number of precision bytes in MP number. *
* *
Expand Down Expand Up @@ -951,6 +957,7 @@ int XMP_Count_Bytes(const digit* number, int precision)
}
return (count);
}
#endif

/***********************************************************************************************
* XMP_Move -- Assign one MP number to another. *
Expand Down
6 changes: 5 additions & 1 deletion common/mssleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
#elif defined(_WIN32)
#include <synchapi.h>
#else /* Assuming recent posix*/
#define __USE_POSIX199309
#ifndef __USE_POSIX199309
#define __USE_POSIX199309 1
#endif
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199309L
#endif
#include <time.h>
#endif

Expand Down
15 changes: 15 additions & 0 deletions common/settings.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "wwstd.h"
#include "settings.h"
#include "ini.h"
#include "miscasm.h"
Expand Down Expand Up @@ -36,6 +37,8 @@ SettingsClass::SettingsClass()

void SettingsClass::Load(INIClass& ini)
{
char buf[128];

/*
** Mouse settings
*/
Expand Down Expand Up @@ -77,6 +80,15 @@ void SettingsClass::Load(INIClass& ini)
if (Video.Boxing || Mouse.RawInput || Mouse.ControllerEnabled) {
Video.HardwareCursor = false;
}

ini.Get_String("Video", "ButtonStyle", "Default", buf, sizeof(buf));
if (!stricmp(buf, "Gold")) {
Video.ButtonStyle = 1;
} else if (!stricmp(buf, "Classic") || !stricmp(buf, "DOS")) {
Video.ButtonStyle = 0;
} else {
Video.ButtonStyle = -1;
}
}

void SettingsClass::Save(INIClass& ini)
Expand Down Expand Up @@ -111,4 +123,7 @@ void SettingsClass::Save(INIClass& ini)
** VQA and WSA interpolation mode 0 = scanlines, 1 = vertical doubling, 2 = linear
*/
ini.Put_Int("Video", "InterpolationMode", Video.InterpolationMode);

ini.Put_String(
"Video", "ButtonStyle", Video.ButtonStyle == -1 ? "Default" : (Video.ButtonStyle == 1 ? "Gold" : "Classic"));
}
1 change: 1 addition & 0 deletions common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class SettingsClass
int InterpolationMode;
bool HardwareCursor;
bool DOSMode;
int ButtonStyle;
std::string Scaler;
std::string Driver;
std::string PixelFormat;
Expand Down
2 changes: 1 addition & 1 deletion common/vqatask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ VQAErrorType VQA_Play(VQAHandle* handle, VQAPlayMode mode)
}

if (data->Flags & VQA_DATA_FLAG_VIDEO_MEMORY_SET) {
++VQAMovieDone;
VQAMovieDone = true;
} else {
rc = (VQAErrorType)VQA_LoadFrame(handle);

Expand Down
6 changes: 3 additions & 3 deletions redalert/cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ void CellClass::Redraw_Objects(bool forced)
#else
optr->Mark(MARK_CHANGE);
#endif
if (optr->Next != NULL && !optr->Next->IsActive) {
optr->Next = NULL;
if (optr->Next != nullptr && !optr->Next->IsActive) {
optr->Next = nullptr;
}
optr = optr->Next;
}
Expand Down Expand Up @@ -604,7 +604,7 @@ void CellClass::Occupy_Down(ObjectClass* object)
*/
if (object->What_Am_I() == RTTI_BUILDING && Cell_Occupier()) {
optr = Cell_Occupier();
while (optr->Next != NULL) {
while (optr->Next != nullptr) {
assert(optr != object);
assert(optr->What_Am_I() != RTTI_BUILDING);
optr = optr->Next;
Expand Down
2 changes: 1 addition & 1 deletion redalert/ending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void Nod_Ending(void)
bool printedtext = false;
while (!done) {
if (!printedtext && !Is_Sample_Playing(kanefinl)) {
printedtext++;
printedtext = true;
Alloc_Object(new ScorePrintClass(Text_String(TXT_SEL_TARGET), 0, 180, _tanpal));
mouseshown = true;
Show_Mouse();
Expand Down
4 changes: 2 additions & 2 deletions redalert/mapedplc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,13 +942,13 @@ int MapEditClass::Place_Object(void)
if (Is_Spot_Free(Pixel_To_Coord(Get_Mouse_X(), Get_Mouse_Y()))) {
obj_coord = Closest_Free_Spot(Pixel_To_Coord(Get_Mouse_X(), Get_Mouse_Y()));
} else {
obj_coord = NULL;
obj_coord = 0;
}

/*
** No free spots; don't place the object
*/
if (obj_coord == NULL) {
if (obj_coord == 0) {
// ScenarioInit--;
return (-1);
}
Expand Down
6 changes: 3 additions & 3 deletions redalert/mapedsel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ int MapEditClass::Move_Grabbed_Object(void)
*/
((InfantryClass*)GrabbedObject)->Clear_Occupy_Bit(GrabbedObject->Coord);
} else {
new_coord = NULL;
new_coord = 0;
}

} else {
Expand All @@ -483,10 +483,10 @@ int MapEditClass::Move_Grabbed_Object(void)
** Try to place object at new coordinate
*/
if (GrabbedObject->Can_Enter_Cell(Coord_Cell(new_coord)) != MOVE_OK) {
new_coord = NULL;
new_coord = 0;
}
}
if (new_coord != NULL) {
if (new_coord != 0) {

/*
** If this object is part of the AI's Base list, change the coordinate
Expand Down
4 changes: 2 additions & 2 deletions redalert/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ void ObjectClass::Debug_Dump(MonoClass* mono) const
{
mono->Set_Cursor(1, 1);
mono->Printf("%-18.18s", Text_String(Full_Name()));
if (Next != NULL) {
if (Next != nullptr) {
mono->Set_Cursor(20, 5);
mono->Printf("%08X", Next->As_Target());
}
Expand Down Expand Up @@ -2451,4 +2451,4 @@ BuildingClass* ObjectTypeClass::Who_Can_Build_Me(bool intheory, bool legal, Hous
}
}
return (anybuilding);
}
}
Loading

0 comments on commit 27e9a7b

Please sign in to comment.