Fixed setting array values in the debug editor.

Some code corrections.
This commit is contained in:
NovaRain
2019-04-06 08:24:49 +08:00
parent 563fdddc7e
commit ae7245579e
10 changed files with 29 additions and 16 deletions
-1
View File
@@ -23,7 +23,6 @@
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.Column0 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+6
View File
@@ -231,6 +231,9 @@ namespace FalloutClient {
BinaryReader br = new BinaryReader(new MemoryStream(buf));
for (int j = 0; j < strings.Length; j++) {
switch (types[j]) {
case DataType.None:
br.BaseStream.Position += 4;
break;
case DataType.Int:
strings[j] = br.ReadInt32().ToString();
break;
@@ -250,6 +253,9 @@ namespace FalloutClient {
BinaryWriter bw = new BinaryWriter(ms);
for (int j = 0; j < strings.Length; j++) {
switch (types[j]) {
case DataType.None:
bw.BaseStream.Position += 4;
break;
case DataType.Int:
bw.Write(int.Parse(strings[j]));
break;
+1 -1
View File
@@ -111,7 +111,7 @@
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.MinimumSize = new System.Drawing.Size(300, 200);
this.Name = "EditorWindow";
this.Text = "Editor Values";
this.Text = "Edit Values";
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
+5
View File
@@ -102,6 +102,11 @@ Delegate<>& OnInputLoop() {
return onInputLoop;
}
void FlushInputBuffer() {
while (!bufferedPresses.empty()) bufferedPresses.pop();
__asm call fo::funcoffs::kb_clear_;
}
DWORD _stdcall KeyDown(DWORD key) {
if ((key & 0x80000000) > 0) { // special flag to check by VK code directly
return GetAsyncKeyState(key & 0xFFFF) & 0x8000;
+3 -2
View File
@@ -31,6 +31,7 @@ extern bool middleMouseDown;
void SetMDown(bool down, bool right);
void SetMPos(int x, int y);
void FlushInputBuffer();
DWORD _stdcall KeyDown(DWORD key);
void _stdcall TapKey(DWORD key);
@@ -43,6 +44,8 @@ Delegate<>& OnInputLoop();
void GetMouse(int* x, int* y);
void _stdcall ForceGraphicsRefresh(DWORD);
#define DIK_ESCAPE 0x01
#define DIK_1 0x02
#define DIK_2 0x03
@@ -190,6 +193,4 @@ void GetMouse(int* x, int* y);
*/
#define DIK_CIRCUMFLEX DIK_PREVTRACK /* Japanese keyboard */
void _stdcall ForceGraphicsRefresh(DWORD);
}
+3 -3
View File
@@ -2582,14 +2582,14 @@ void BugFixes::init()
0x499013 // PrintAMelevList_
});
// Fix "out of bounds" bug when printing the automap list
HookCall(0x499240, PrintAMList_hook);
// Fix for a duplicate obj_dude script being created when loading a saved game
HookCall(0x48D63E, obj_load_dude_hook0);
HookCall(0x48D666, obj_load_dude_hook1);
BlockCall(0x48D675);
BlockCall(0x48D69D);
// Fix "out of bounds" bug when printing the automap list
HookCall(0x499240, PrintAMList_hook);
}
}
+1
View File
@@ -202,6 +202,7 @@ static void RunEditorInternal(SOCKET &s) {
delete[] sglobals;
delete[] arrays;
FlushInputBuffer();
*(DWORD*)FO_VAR_script_engine_running = 1;
}
+5 -7
View File
@@ -92,7 +92,7 @@ std::vector<FakePerk> fakeTraits;
std::vector<FakePerk> fakePerks;
std::vector<FakePerk> fakeSelectablePerks; // available perks for selection in the perk selection list
static std::list<int> RemoveTraitID;
static long RemoveTraitID = -1;
static std::list<int> RemovePerkID;
static std::list<int> RemoveSelectableID;
@@ -605,7 +605,7 @@ static void _stdcall AddFakePerk(DWORD perkID) {
}
}
if (!matched) {
RemoveTraitID.push_back(count); // index of the added trait
if (RemoveTraitID == -1) RemoveTraitID = count; // index of the added trait
fakeTraits.push_back(fakeSelectablePerks[perkID]);
}
}
@@ -1314,16 +1314,14 @@ void _stdcall ClearSelectablePerks() {
}
void PerksEnterCharScreen() {
RemoveTraitID.clear();
RemoveTraitID = -1;
RemovePerkID.clear();
RemoveSelectableID.clear();
}
void PerksCancelCharScreen() {
if (RemoveTraitID.size() > 1) RemoveTraitID.sort();
while (!RemoveTraitID.empty()) {
fakeTraits.erase(fakeTraits.begin() + RemoveTraitID.back());
RemoveTraitID.pop_back();
if (RemoveTraitID != -1) {
fakeTraits.erase(fakeTraits.begin() + RemoveTraitID, fakeTraits.end());
}
if (RemovePerkID.size() > 1) RemovePerkID.sort(); // sorting to correctly remove from the end
while (!RemovePerkID.empty()) {
+3
View File
@@ -345,6 +345,9 @@ void DESetArray(int id, const DWORD* types, const char* data) {
for (size_t i = 0; i < arrays[id].val.size(); i++) {
auto& arVal = arrays[id].val[i];
switch (arVal.type) {
case DataType::NONE:
pos += 4;
break;
case DataType::INT:
arVal.intVal = *(long*)(data + pos);
pos += 4;
+2 -2
View File
@@ -74,7 +74,7 @@ struct ProtoModify {
std::forward_as_tuple(newProto, objPID));
} else {
s_proto = it->second.proto;
if (s_proto == nullptr) { // prototype has not been created yet
if (s_proto == nullptr) { // prototype has not been created
it->second.sharedCount = CreateProtoMem(it, defaultProto, s_proto);
it->second.proto = s_proto;
}
@@ -504,7 +504,7 @@ bool Stats::LoadStatData(HANDLE file) {
if (sizeRead != 20) return true;
s_baseStatProto.emplace_back(data);
if (protoMem.find(data.objID) == protoMem.end()) {
protoMem.emplace(data.objID, data.objPID); // protoMem[data.objID] = ProtoMem(data.objPID);
protoMem.emplace(data.objID, data.objPID);
}
}
ReadFile(file, &count, 4, &sizeRead, 0);