Code edits on Graphics.cpp & ScriptExtender.cpp.

Minor edits on some other code.
Added the missing Test_ForceFloats option to ddraw.ini.
This commit is contained in:
NovaRain
2019-05-07 14:04:36 +08:00
parent 5d9008f407
commit c1ec4057a6
9 changed files with 46 additions and 46 deletions
+4
View File
@@ -17,6 +17,10 @@ NumSoundBuffers=0
;Set to 1 to allow attaching sound files to combat float messages
AllowSoundForFloats=1
;Set to 1 to force critters to display combat float messages
;Requires sfall debugging mode and AllowSoundForFloats to be enabled
Test_ForceFloats=0
;Set to 1 to automatically search for alternative formats (mp3/wma/wav) when Fallout tries to play an acm
;Set to 2 to play alternative music files even if original acm files are not present in the music folder
;This does not effect the play_sfall_sound and stop_sfall_sound script functions
+3 -4
View File
@@ -895,15 +895,14 @@ TGameObj* __stdcall InvenRightHand(TGameObj* critter) {
}
}
long __stdcall CreateWindowFunc(const char* winName, long x, long y, long width, long height, long bgColorIndex, long flags) {
long __fastcall CreateWindowFunc(const char* winName, long x, long y, long width, long height, long bgColorIndex, long flags) {
__asm {
push flags;
push bgColorIndex;
push height;
mov ecx, width;
mov eax, ecx;
mov ebx, y;
mov edx, x;
mov eax, winName;
mov ecx, width;
call createWindow_;
}
}
+1 -1
View File
@@ -1004,7 +1004,7 @@ void __declspec() DebugPrintf(const char* fmt, ...);
const char* __stdcall FindCurrentProc(TProgram* program);
// creates a window with the name and flags
long __stdcall CreateWindowFunc(const char* winName, long x, long y, long width, long height, long bgColorIndex, long flags);
long __fastcall CreateWindowFunc(const char* winName, long x, long y, long width, long height, long bgColorIndex, long flags);
// creates a button
long __stdcall WinRegisterButton(DWORD winRef, long xPos, long yPos, long width, long height, long hoverOn, long hoverOff, long buttonDown, long buttonUp, BYTE* pictureUp, BYTE* pictureDown, long arg12, long buttonType);
+27 -30
View File
@@ -135,20 +135,16 @@ static D3DXHANDLE gpuBltHeadCorner;
static float rcpres[2];
static size_t shadersSize;
struct sShader {
ID3DXEffect* Effect;
bool Active;
D3DXHANDLE ehTicks;
DWORD mode;
DWORD mode2;
bool Active;
sShader() {
Effect = 0;
Active = false;
ehTicks = 0;
mode = 0;
mode2 = 0;
}
sShader() : Effect(0), ehTicks(0), mode(0), mode2(0), Active(false) {}
};
static std::vector<sShader> shaders;
@@ -190,7 +186,7 @@ void rcpresInit() {
}
void _stdcall SetShaderMode(DWORD d, DWORD mode) {
if (d >= shaders.size() || !shaders[d].Effect) return;
if (d >= shadersSize || !shaders[d].Effect) return;
if (mode & 0x80000000) {
shaders[d].mode2 = mode ^ 0x80000000;
} else {
@@ -201,8 +197,8 @@ void _stdcall SetShaderMode(DWORD d, DWORD mode) {
int _stdcall LoadShader(const char* path) {
if (!GraphicsMode || strstr(path, "..") || strstr(path, ":")) return -1;
char buf[MAX_PATH];
sprintf(buf, "%s\\shaders\\%s", *(char**)_patches, path);
for (DWORD d = 0; d < shaders.size(); d++) {
sprintf_s(buf, "%s\\shaders\\%s", *(char**)_patches, path);
for (DWORD d = 0; d < shadersSize; d++) {
if (!shaders[d].Effect) {
if (FAILED(D3DXCreateEffectFromFile(d3d9Device, buf, 0, 0, 0, 0, &shaders[d].Effect, 0))) return -1;
else return d;
@@ -217,30 +213,31 @@ int _stdcall LoadShader(const char* path) {
const char* name;
IDirect3DTexture9* tex;
sprintf_s(buf, "texname%d", i);
sprintf(buf, "texname%d", i);
if (FAILED(shader.Effect->GetString(buf, &name))) break;
sprintf_s(buf, "%s\\art\\stex\\%s", *(char**)_patches, name);
if (FAILED(D3DXCreateTextureFromFileA(d3d9Device, buf, &tex))) continue;
sprintf_s(buf, "tex%d", i);
sprintf(buf, "tex%d", i);
shader.Effect->SetTexture(buf, tex);
shaderTextures.push_back(tex);
}
shader.ehTicks = shader.Effect->GetParameterByName(0, "tickcount");
shaders.push_back(shader);
return shaders.size() - 1;
shadersSize = shaders.size();
return shadersSize - 1;
}
void _stdcall ActivateShader(DWORD d) {
if (d < shaders.size() && shaders[d].Effect) shaders[d].Active = true;
if (d < shadersSize && shaders[d].Effect) shaders[d].Active = true;
}
void _stdcall DeactivateShader(DWORD d) {
if (d < shaders.size()) shaders[d].Active = false;
if (d < shadersSize) shaders[d].Active = false;
}
int _stdcall GetShaderTexture(DWORD d, DWORD id) {
if (id < 1 || id > 128 || d >= shaders.size() || !shaders[d].Effect) return -1;
if (id < 1 || id > 128 || d >= shadersSize || !shaders[d].Effect) return -1;
IDirect3DBaseTexture9* tex = 0;
char buf[8] = "tex";
_itoa_s(id, &buf[3], 4, 10);
@@ -253,29 +250,29 @@ int _stdcall GetShaderTexture(DWORD d, DWORD id) {
}
void _stdcall FreeShader(DWORD d) {
if (d < shaders.size()) {
if (d < shadersSize) {
SAFERELEASE(shaders[d].Effect);
shaders[d].Active = false;
}
}
void _stdcall SetShaderInt(DWORD d, const char* param, int value) {
if (d >= shaders.size() || !shaders[d].Effect) return;
if (d >= shadersSize || !shaders[d].Effect) return;
shaders[d].Effect->SetInt(param, value);
}
void _stdcall SetShaderFloat(DWORD d, const char* param, float value) {
if (d >= shaders.size() || !shaders[d].Effect) return;
if (d >= shadersSize || !shaders[d].Effect) return;
shaders[d].Effect->SetFloat(param, value);
}
void _stdcall SetShaderVector(DWORD d, const char* param, float f1, float f2, float f3, float f4) {
if (d >= shaders.size() || !shaders[d].Effect) return;
if (d >= shadersSize || !shaders[d].Effect) return;
shaders[d].Effect->SetFloatArray(param, &f1, 4);
}
void _stdcall SetShaderTexture(DWORD d, const char* param, DWORD value) {
if (d >= shaders.size() || !shaders[d].Effect || value >= shaderTextures.size()) return;
if (d >= shadersSize || !shaders[d].Effect || value >= shaderTextures.size()) return;
shaders[d].Effect->SetTexture(param, shaderTextures[value]);
}
@@ -323,7 +320,7 @@ static void ResetDevice(bool CreateNew) {
} else {
d3d9Device->Reset(&params);
if (gpuBltEffect) gpuBltEffect->OnResetDevice();
for (DWORD d = 0; d < shaders.size(); d++) {
for (DWORD d = 0; d < shadersSize; d++) {
if (shaders[d].Effect) shaders[d].Effect->OnResetDevice();
}
}
@@ -448,7 +445,7 @@ static void Present() {
SAFERELEASE(movieBuffer);
SAFERELEASE(gpuPalette);
if (gpuBltEffect) gpuBltEffect->OnLostDevice();
for (DWORD d = 0; d < shaders.size(); d++) {
for (DWORD d = 0; d < shadersSize; d++) {
if (shaders[d].Effect) shaders[d].Effect->OnLostDevice();
}
DeviceLost = true;
@@ -463,7 +460,7 @@ void RefreshGraphics() {
d3d9Device->SetStreamSource(0, vBuffer, 0, sizeof(MyVertex));
d3d9Device->SetRenderTarget(0, sSurf1);
if (GPUBlt && shaders.size()) {
if (GPUBlt && shadersSize) {
UINT unused;
gpuBltEffect->Begin(&unused, 0);
gpuBltEffect->BeginPass(0);
@@ -475,7 +472,7 @@ void RefreshGraphics() {
} else {
d3d9Device->SetTexture(0, Tex);
}
for (int d = shaders.size() - 1; d >= 0; d--) {
for (int d = shadersSize - 1; d >= 0; d--) {
if (!shaders[d].Effect || !shaders[d].Active) continue;
if (shaders[d].mode2 && !(shaders[d].mode2 & GetCurrentLoops())) continue;
if (shaders[d].mode & GetCurrentLoops()) continue;
@@ -496,7 +493,7 @@ void RefreshGraphics() {
d3d9Device->SetStreamSource(0, vBuffer2, 0, sizeof(MyVertex));
d3d9Device->SetRenderTarget(0, backbuffer);
if (GPUBlt && !shaders.size()) {
if (GPUBlt && !shadersSize) {
UINT unused;
gpuBltEffect->Begin(&unused, 0);
gpuBltEffect->BeginPass(0);
@@ -592,8 +589,9 @@ void Gfx_SetDefaultTechnique() {
}
void GraphicsResetOnGameLoad() {
for (DWORD d = 0; d < shaders.size(); d++) SAFERELEASE(shaders[d].Effect);
for (DWORD d = 0; d < shadersSize; d++) SAFERELEASE(shaders[d].Effect);
shaders.clear();
shadersSize = 0;
}
class FakePalette2 : IDirectDrawPalette {
@@ -926,9 +924,8 @@ public:
ULONG _stdcall Release() {
if (!--Refs) {
for (DWORD d = 0; d < shaders.size(); d++) SAFERELEASE(shaders[d].Effect);
GraphicsResetOnGameLoad();
for (DWORD d = 0; d < shaderTextures.size(); d++) shaderTextures[d]->Release();
shaders.clear();
shaderTextures.clear();
SAFERELEASE(backbuffer);
SAFERELEASE(sSurf1);
+1
View File
@@ -27,6 +27,7 @@
extern DWORD GraphicsMode;
extern DWORD GPUBlt;
extern IDirect3D9* d3d9;
extern IDirect3DDevice9* d3d9Device;
void GraphicsResetOnGameLoad();
+1 -1
View File
@@ -99,7 +99,7 @@ DWORD __stdcall sf_item_total_size(TGameObj* critter) {
mov totalSize, eax;
}
if ((critter->artFID & 0xF000000) == (OBJ_TYPE_CRITTER << 24)) {
if (((critter->artFID >> 24) & 0xF0) == OBJ_TYPE_CRITTER) {
TGameObj* item = InvenRightHand(critter);
if (item && !(item->flags & 0x2000000)) { // ObjectFlag Right_Hand
totalSize += ItemSize(item);
+4 -3
View File
@@ -218,7 +218,8 @@ public:
// returns argument with given index, possible shifted by argShift
const ScriptValue& arg(int index) const {
return _args.at(index + _argShift);
assert((index + _argShift) < OP_MAX_ARGUMENTS);
return _args[index + _argShift];
}
// current return value
@@ -312,9 +313,9 @@ public:
// retrieve string argument
if (type == DATATYPE_STR) {
_args.at(i) = InterpretGetString(program, rawValue, rawValueType);
_args[i] = InterpretGetString(program, rawValue, rawValueType);
} else {
_args.at(i) = ScriptValue(type, rawValue);
_args[i] = ScriptValue(type, rawValue);
}
}
// flag that arguments passed are valid
+1 -3
View File
@@ -18,7 +18,7 @@
#include "main.h"
#include <vector> // should be above DX SDK includes to avoid warning 4995
//#include <vector> // should be above DX SDK includes to avoid warning 4995
#include <d3d9.h>
#include <dshow.h>
@@ -32,8 +32,6 @@
static DWORD MoviePtrs[MaxMovies];
char MoviePaths[MaxMovies * 65];
extern IDirect3D9* d3d9;
class CAllocator : public IVMRSurfaceAllocator9, IVMRImagePresenter9 {
private:
IDirect3DSurface9* surface;