This document records important fixes made to the OpenSoF2MP codebase for future reference.
Problem: Cast from pointer types to int loses precision on 64-bit systems.
Affected Files:
/code/client/snd_mem.cpp/code/Ratl/ratl_common.h
Specific Fixes:
-
In
snd_mem.cppline 122:- Changed
Com_Printf ("0x%x : %s (%d)\n", (int)(data_p - 4), str, iff_chunk_len); - To
Com_Printf ("0x%p : %s (%d)\n", (void*)(data_p - 4), str, iff_chunk_len);
- Changed
-
In
snd_mem.cppline 196:- Fixed
info.dataofs = data_p - wav;to be cast appropriately
- Fixed
-
In
ratl_common.hmultiple locations:- Changed
int(&((TStorage *)0)->nodeData)-int(&((TStorage *)0)->value) - To
(ptrdiff_t)(&((TStorage *)0)->nodeData)-(ptrdiff_t)(&((TStorage *)0)->value) - Also updated similar pointer arithmetic patterns to use
ptrdiff_twhere appropriate
- Changed
Problem: Missing includes for std::string type.
Affected Files:
/code/client/snd_mem.cpp/code/client/snd_music.cpp/code/client/snd_ambient.cpp
Fix: Added the following include to each file:
#ifdef __cplusplus
#include <string>
using std::string;
#endif- Use
ptrdiff_tfor pointer arithmetic results that need to be stored as integers - Use
%pformat specifier for printing pointer values - Always include appropriate standard library headers when using STL types