Compare commits

..
24 Commits
Author SHA1 Message Date
NovaRain 78dfb530a9 Moved LoadHeroAppearance() from MainMenuHook to NewGame2. No reason to run it on the main menu where player appearance can't display. 2017-09-19 15:27:08 +08:00
NovaRain d588f2e691 Edited code style in HeroAppearance.cpp/h, also removed some redundant blank lines. 2017-09-19 10:43:31 +08:00
NovaRain daf7a82997 Added descriptions for the variables in Perks.ini.
(cherry picked from commit 848f29b468)
2017-09-12 15:39:39 +08:00
NovaRain 9ad2b19e1a Removed the redundant LoadHeroAppearance calling.
(now it's called during LoadGame_, which is earlier than LoadGame2_After)
2017-09-09 18:59:21 +08:00
NovaRain 4b66dd3682 Reverted LoadGame to previous revision, but also kept EndLoadHook and changed it to only call LoadHeroAppearance.
(attempted to fix issue #117 and #94)
2017-09-05 09:21:22 +08:00
NovaRain 4899aeece1 Changed new function names in the previous commit to PascalCase style. 2017-09-01 09:45:33 +08:00
NovaRainandGitHub 946266e367 Merge pull request #107 from FakelsHub/crafty_features/combat_proc
Added calls to unimplemented script procedures: combat_is_starting_p_proc/combat_is_over_p_proc (from Crafty)
2017-09-01 09:40:47 +08:00
NovaRain 438ea071fc Removed the backported new modes for get_game_mode in commit a93ad5a9ba. 2017-08-24 21:46:42 +08:00
NovaRain 89760235c7 Removed unimplemented HEROWIN game mode from header files.
Cleared some obsoleted/unused code from main.cpp & LoadGameHook.cpp.
2017-08-23 13:42:58 +08:00
NovaRain 321f1c6034 Fixed the double damage effect of Silent Death perk not being applied to critical hits (from Crafty) 2017-08-21 23:18:32 +08:00
NovaRain 513338f160 Fixed incorrect argument description for get/set_proto_data in sfall opcode list.txt.
Removed incorrect PROTO_CR_FLAGS value in define_extra.h (was actually critter's IN), and renamed PROTO_CR_ACTION_FLAGS to its correct name #112

(cherry picked from commit ad17773ace)
2017-08-21 11:33:37 +08:00
NovaRain 08b92542f4 Fixed the incorrect description in HOOK_COMBATDAMAGE.
(cherry picked from commit 85cdd8973e)
2017-08-19 08:49:56 +08:00
NovaRain 46013c94b0 Added SSL library files and define_lite.h (from 4.0 development branch) 2017-08-18 15:52:14 +08:00
NovaRain 7a4ab59089 Added missing description for set_car_current_town.
Removed trailing spaces in MetaruleOp.hpp.
2017-08-13 11:38:18 +08:00
NovaRain e505e204cb Two bug fixes from Crafty:
1. Fixed the displayed message when the attack randomly hits a target that is not a critter and has a script attached.
2. Fixed damage_p_proc being called for misses if the target is not a critter.
2017-08-07 13:24:11 +08:00
NovaRain 7343754d53 Fixed Bonus Move APs being replenished when you save and load the game in combat (from Crafty)
Replaced all usages of MakeCall with 3 arguments with either MakeJump or MakeCall (2 arguments) to improve code readability (ref. commit 96fa2668cc)
2017-07-26 23:13:40 +08:00
NovaRain ae1e17d359 Added a note for argnum in set_sfall_arg().
Fixed incorrect set_sfall_arg usage in the example.
Removed a redundant line in sfall opcode list.txt.
2017-07-25 23:14:50 +08:00
NovaRain 32dbe5581d Replaced hs_*.int scripts in example mods with normal global scripts with register_hook.
(cherry picked from commit e7e286013f)
2017-07-06 21:04:51 +08:00
NovaRain a93ad5a9ba Added new modes for get_game_mode to match Crafty's (backported from 4.0 development branch, commit c32dc7664e) 2017-06-22 09:41:05 +08:00
NovaRain 874b047ce1 Added Attack Type argument for HOOK_COMBATDAMAGE (from Crafty) #100 2017-06-14 12:45:13 +08:00
NovaRain afa590c5a8 Minor edits to ddraw.ini. 2017-06-02 11:49:02 +08:00
NovaRain b89c52fcec Added DontTurnOffSneakIfYouRun option to prevent the player from running while sneaking without Silent Running perk (from Crafty)
Added sfall log text for DisablePipboyAlarm.
2017-05-26 10:10:16 +08:00
NovaRain ec2d323f75 Changed LoadGame2_After to be called before LoadGame state is ended (backported from 4.0 development branch, commit c2e6d743a3)
Updated version number.
Minor edits to scripting documents.
2017-05-23 21:05:04 +08:00
Mr.Stalin 586679b07f Added scripting procedure handlers combat_is_starting_p_proc/combat_is_over_p_proc from Crafry. 2017-05-12 18:28:46 +03:00
614 changed files with 35097 additions and 88926 deletions
-1
View File
@@ -1 +0,0 @@
*.ssl linguist-language=Pascal
-12
View File
@@ -1,12 +0,0 @@
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
# target-branch: "develop"
labels:
- "dependencies"
-62
View File
@@ -1,62 +0,0 @@
name: Build
on:
push:
branches:
- 'master'
- 'develop'
- 'github-action'
paths:
- '.github/workflows/build.yml'
- 'action.yml'
- 'sfall/**'
pull_request:
branches:
- 'master'
- 'develop'
paths:
- '.github/workflows/build.yml'
- 'action.yml'
- 'sfall/**'
jobs:
Build:
name: sfall
runs-on: windows-2022
steps:
- name: Clone sfall
uses: actions/checkout@v6
# Action is used twice for self-testing only
# DevXP build results are intentionally *not* included in artifact
- name: ReleaseXP build
id: build
uses: ./
with:
release-xp: true
dev-xp: false
- name: DevXP build
uses: ./
with:
release-xp: false
dev-xp: true
- name: Prepare artifacts
run: |
:
mkdir -p sfall-build
cp artifacts/ddraw.ini sfall-build
cp artifacts/sfall_dat/sfall.dat sfall-build
cp "${{ steps.build.outputs.release-xp }}" sfall-build
shell: bash
- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: sfall-build
path: sfall-build
retention-days: 30
-34
View File
@@ -1,34 +0,0 @@
name: github pages
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Install dependencies
run: |
sudo apt update && sudo apt -y -qq install bundler python3-pip
pip3 install ruamel.yaml --user
- name: Build
run: ./docs/generate.sh
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_site
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
-11
View File
@@ -26,7 +26,6 @@
*.exe
*.out
*.app
!ducible.exe
# NetBeans
nbproject/private/
@@ -47,8 +46,6 @@ nb-configuration.xml
*.user
*.userosscache
*.sln.docstates
*.VC.db
*.VC.opendb
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
@@ -56,10 +53,8 @@ nb-configuration.xml
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Dd]evXP/
[Rr]elease/
[Rr]eleases/
[Rr]eleaseXP/
x64/
x86/
build/
@@ -225,9 +220,3 @@ FakesAssemblies/
# Visual Studio 6 workspace options file
*.opt
sfall/postbuild.cmd
# jekyll build files
docs/_site
docs/.sass-cache
docs/.jekyll-metadata
docs/pages/*.md
-1120
View File
File diff suppressed because it is too large Load Diff
-394
View File
@@ -1,394 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using File = System.IO.File;
using StreamReader = System.IO.StreamReader;
using MemoryStream = System.IO.MemoryStream;
using BinaryReader = System.IO.BinaryReader;
using BinaryWriter = System.IO.BinaryWriter;
namespace FalloutClient {
public partial class DebugEditor : Form
{
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Explicit)]
private struct ByteConverter {
[System.Runtime.InteropServices.FieldOffset(0)]
private int i;
[System.Runtime.InteropServices.FieldOffset(0)]
private float f;
public int GetAsInt(float f) {
this.f = f;
return i;
}
public float GetAsFloat(int i) {
this.i = i;
return f;
}
public byte[] GetAsBytes(ulong ul) {
byte[] b = new byte[8];
for (int i = 0; i < 8; i++) b[i] = (byte)((ul & ((ulong)0xff << (i * 8))) >> (i * 8));
return b;
}
}
private static ByteConverter converter = new ByteConverter();
private enum Mode { Globals, MapVars, SGlobals, Arrays, Critters, LocalVars }
private readonly EditorConnection connection;
private Mode mode;
private readonly Dictionary<int, string> GlobNames = new Dictionary<int, string>();
private readonly Dictionary<uint, string> CritNames = new Dictionary<uint, string>();
private void Redraw() {
bCrittersLvar.Enabled = false;
bEdit.Enabled = false;
Column2.ReadOnly = false;
Column3.ReadOnly = false;
Column2.HeaderText = "Value (Int)";
Column3.HeaderText = "Value (Float)";
dataGridView1.SelectionMode = DataGridViewSelectionMode.CellSelect;
dataGridView1.SuspendLayout();
dataGridView1.Rows.Clear();
switch (mode) {
case Mode.Globals:
for (int i = 0; i < connection.Globals.Length; i++) {
string name = GlobNames.ContainsKey(i) ? GlobNames[i] : "";
dataGridView1.Rows.Add(i, name, connection.Globals[i], converter.GetAsFloat(connection.Globals[i]));
}
break;
case Mode.MapVars:
for (int i = 0; i < connection.MapVars.Length; i++) {
dataGridView1.Rows.Add(i, "", connection.MapVars[i], converter.GetAsFloat(connection.MapVars[i]));
}
break;
case Mode.SGlobals:
for (int i = 0; i < connection.SGlobalKeys.Length; i++) {
string s = connection.SGlobalKeys[i] > 0xffffffff
? new string(System.Text.ASCIIEncoding.ASCII.GetChars(converter.GetAsBytes(connection.SGlobalKeys[i])))
: (connection.SGlobalKeys[i].ToString());
dataGridView1.Rows.Add(s, "", connection.sGlobals[i], converter.GetAsFloat(connection.sGlobals[i]));
}
break;
case Mode.Arrays:
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
Column2.ReadOnly = true;
Column3.ReadOnly = true;
Column2.HeaderText = "Array size";
Column3.HeaderText = "Array flags";
bEdit.Enabled = true;
for (int i = 0; i < connection.Arrays.Length; i++) {
bool isMap = connection.ArrayIsMap[i];
int arrlen = connection.ArrayLengths[i];
if (isMap) arrlen /= 2;
dataGridView1.Rows.Add(connection.Arrays[i], isMap ? "Map" : "", arrlen, "0x" + connection.ArrayFlag[i].ToString("x").ToUpper());
}
break;
case Mode.Critters:
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
Column2.ReadOnly = true;
Column3.ReadOnly = true;
Column2.HeaderText = "PID";
Column3.HeaderText = "Pointer";
bEdit.Enabled = true;
bCrittersLvar.Enabled = true;
for (int i = 0; i < connection.Critters.Length / 2; i++) {
uint modcrit = (connection.Critters[i, 0] & 0xfffff);
string name = CritNames.ContainsKey(modcrit) ? CritNames[modcrit] : "";
dataGridView1.Rows.Add(i + 1, name, connection.Critters[i, 0].ToString("x").ToUpper(), connection.Critters[i, 1].ToString());
}
break;
}
dataGridView1.ResumeLayout();
}
internal DebugEditor(EditorConnection connection) {
InitializeComponent();
this.connection = connection;
mode = Mode.Globals;
if (File.Exists(".\\data\\data\\vault13.gam")) {
StreamReader sr=new StreamReader(".\\data\\data\\vault13.gam");
int gvar = 0;
while (!sr.EndOfStream) {
string line = sr.ReadLine().TrimStart();
if (line.StartsWith("GVAR_")) GlobNames[gvar++] = line.Remove(line.IndexOf(':')).TrimEnd();
}
sr.Close();
} else if (File.Exists("globals.txt")) {
StreamReader sr = new StreamReader("globals.txt");
while (!sr.EndOfStream) {
string[] line = sr.ReadLine().Split(' ');
GlobNames[int.Parse(line[0])] = line[1];
}
sr.Close();
}
if (File.Exists("critters.txt")) {
StreamReader sr = new StreamReader("critters.txt");
while (!sr.EndOfStream) {
string line = sr.ReadLine();
CritNames[uint.Parse(line.Remove(line.IndexOf(' ')))] = line.Substring(line.IndexOf(' ') + 1);
}
sr.Close();
}
Redraw();
redrawTimer.Start();
}
private void DebugEditor_FormClosing(object sender, FormClosingEventArgs e) {
connection.WriteDataType(DataTypeSend.Exit);
connection.Close();
}
private void bGlobals_Click(object sender, EventArgs e) {
mode = Mode.Globals;
Redraw();
}
private void bMapVars_Click(object sender, EventArgs e) {
mode = Mode.MapVars;
Redraw();
}
private void bSGlobals_Click(object sender, EventArgs e) {
mode = Mode.SGlobals;
Redraw();
}
private void bArrays_Click(object sender, EventArgs e) {
mode = Mode.Arrays;
Redraw();
}
private void bCritters_Click(object sender, EventArgs e) {
mode = Mode.Critters;
Redraw();
}
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) {
int[] array = null;
DataTypeSend dts;
switch (mode) {
case Mode.Globals:
array = connection.Globals;
dts = DataTypeSend.SetGlobal;
break;
case Mode.MapVars:
array = connection.MapVars;
dts = DataTypeSend.SetMapVar;
break;
case Mode.SGlobals:
array = connection.sGlobals;
dts = DataTypeSend.SetSGlobal;
break;
default:
return;
}
redrawTimer.Stop();
if (e.ColumnIndex == 2) {
string str = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
int val;
if (str == null || !int.TryParse(str, out val)) {
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = array[e.RowIndex];
} else {
array[e.RowIndex] = val;
connection.WriteDataType(dts);
connection.WriteInt(e.RowIndex);
connection.WriteInt(val);
}
} else {
string str = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
float val;
if (str == null || !float.TryParse(str, out val)) {
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = array[e.RowIndex];
} else {
array[e.RowIndex] = converter.GetAsInt(val);
connection.WriteDataType(dts);
connection.WriteInt(e.RowIndex);
connection.WriteInt(converter.GetAsInt(val));
}
}
redrawTimer.Start();
}
private void bEdit_Click(object sender, EventArgs e) {
if (dataGridView1.SelectedRows.Count == 0) return;
int i = (int)dataGridView1.SelectedRows[0].Tag;
redrawTimer.Stop();
switch (mode) {
case Mode.Arrays: {
DataType[] types = new DataType[connection.ArrayLengths[i]];
int[] lenType = new int[connection.ArrayLengths[i]];
string[] strings = new string[connection.ArrayLengths[i]];
connection.WriteDataType(DataTypeSend.GetArray); // code
connection.WriteInt(i); // index
int lenData = 0;
for (int j = 0; j < strings.Length; j++) {
types[j] = (DataType)connection.ReadInt();
lenType[j] = connection.ReadInt(); // len data of type
lenData += lenType[j];
}
byte[] buf = connection.ReadBytes(lenData); // read data
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;
case DataType.Float:
strings[j] = br.ReadSingle().ToString();
break;
case DataType.String:
byte[] bytes = br.ReadBytes(lenType[j]);
strings[j] = System.Text.Encoding.ASCII.GetString(bytes, 0, Array.IndexOf<byte>(bytes, 0));
break;
}
}
br.Close();
strings = EditorWindow.ShowEditor(this, null, types, strings, connection.ArrayIsMap[i]);
if (strings != null) { // save
MemoryStream ms = new MemoryStream(lenData);
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;
case DataType.Float:
bw.Write(float.Parse(strings[j]));
break;
case DataType.String:
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(strings[j]);
if (bytes.Length < lenType[j])
bw.Write(bytes);
else
bw.Write(bytes, 0, lenType[j] - 1);
bw.Write((byte)0);
break;
}
}
// send data to sfall
connection.WriteDataType(DataTypeSend.SetArray);
connection.WriteInt(i); // index
connection.WriteInt(lenData);
connection.WriteBytes(ms.GetBuffer(), 0, lenData);
bw.Close();
}
}
break;
case Mode.Critters: {
DataType[] types = new DataType[33];
string[] strings = new string[33];
string[] names = new string[33];
connection.WriteDataType(DataTypeSend.RetrieveCritter);
connection.WriteInt(i);
BinaryReader br = new BinaryReader(new System.IO.MemoryStream(connection.ReadBytes(33 * 4)));
for (int j = 0; j < 33; j++) {
types[j] = DataType.Int;
strings[j] = br.ReadInt32().ToString();
}
br.Close();
names[0] = " ID";
names[1] = " Tile";
names[6] = " Current frame";
names[7] = " Rotation";
names[8] = " FID";
names[9] = " Flags";
names[10] = " Elevation";
names[11] = " Inventory count";
names[13] = " Inventory pointer";
names[14] = " Reaction";
names[15] = " Combat state";
names[16] = " Current AP";
names[17] = " Combat flags";
names[18] = " Last Turn Damage";
names[19] = " AI Packet";
names[20] = " Team";
names[21] = " Who hit me";
names[22] = " HP";
names[23] = " Rads";
names[24] = " Poison";
names[25] = " Proto ID";
names[26] = " Combat ID";
names[29] = " Outline flags";
names[30] = " Script ID";
names[32] = " Script index";
strings = EditorWindow.ShowEditor(this, names, types, strings);
if (strings != null) {
MemoryStream ms = new MemoryStream(33 * 4);
BinaryWriter bw = new BinaryWriter(ms);
for (int j = 0; j < 33; j++) bw.Write(int.Parse(strings[j]));
connection.WriteDataType(DataTypeSend.SetCritter);
connection.WriteInt(i);
connection.WriteBytes(ms.GetBuffer(), 0, 33 * 4);
bw.Close();
}
}
break;
}
redrawTimer.Start();
}
private void bCrittersLvar_Click(object sender, EventArgs e) {
if (dataGridView1.SelectedRows.Count == 0) return;
int i = (int)dataGridView1.SelectedRows[0].Tag;
connection.WriteDataType(DataTypeSend.RetrieveCritter);
connection.WriteInt(i);
BinaryReader br = new BinaryReader(new System.IO.MemoryStream(connection.ReadBytes(33 * 4)));
br.BaseStream.Position = 30 * 4;
int sid = br.ReadInt32();
br.Close();
if (sid != -1) {
connection.WriteDataType(DataTypeSend.GetLocal);
connection.WriteInt(sid);
int totalVar = connection.ReadInt();
string[] values = new string[totalVar];
if (totalVar > 0) {
br = new BinaryReader(new System.IO.MemoryStream(connection.ReadBytes(totalVar * 4)));
for (int j = 0; j < totalVar; j++) {
values[j] = br.ReadInt32().ToString();
}
br.Close();
}
values = EditorWindow.ShowEditor(this, values);
if (values != null) {
int countVar = values.Length;
MemoryStream ms = new MemoryStream(countVar * 4);
BinaryWriter bw = new BinaryWriter(ms);
for (int j = 0; j < countVar; j++) bw.Write(int.Parse(values[j]));
connection.WriteDataType(DataTypeSend.SetLocal);
connection.WriteInt(sid);
connection.WriteInt(countVar);
connection.WriteBytes(ms.GetBuffer(), 0, countVar * 4);
bw.Close();
}
} else {
MessageBox.Show("This critter has no script attached.");
}
}
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) {
bEdit.PerformClick();
}
private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e) {
dataGridView1.Rows[e.RowIndex].Tag = e.RowIndex;
}
private void timer1_Tick(object sender, EventArgs e) {
connection.WriteDataType(DataTypeSend.RedrawGame);
}
}
}
-131
View File
@@ -1,131 +0,0 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace FalloutClient {
public enum DataType : int { None = 0, Int = 1, Float = 2, String = 3 }
public partial class EditorWindow : Form
{
private readonly DataType[] types = null;
private string[] values;
private bool save;
private static bool valueInHex = false;
private void ConvertValues(bool toHex) {
for (int i = 0; i < values.Length; i++) {
if (toHex) {
if (types == null || types[i] == DataType.Int) {
int val = int.Parse(values[i]);
values[i] = "0x" + val.ToString("x").ToUpper();
}
} else {
if (types == null || types[i] == DataType.Int) {
values[i] = Convert.ToInt32(values[i], 16).ToString();
}
}
}
}
private EditorWindow(string[] names, DataType[] types, string[] values, bool isMap) {
this.types = types;
this.values = values;
InitializeComponent();
checkBox.Checked = EditorWindow.valueInHex;
dataGridView1.SuspendLayout();
if (valueInHex) ConvertValues(true);
if (names == null)
for (int i = 0; i < types.Length; i++) {
string element = i.ToString();
if (isMap && (i % 2) == 0) element += " - Key";
dataGridView1.Rows.Add(element, types[i].ToString(), values[i]);
}
else
for (int i = 0; i < types.Length; i++) dataGridView1.Rows.Add("[0x" + (i * 4).ToString("x").ToUpper() + "]" + names[i], types[i].ToString(), values[i]);
dataGridView1.ResumeLayout();
}
public static string[] ShowEditor(DebugEditor form, string[] names, DataType[] types, string[] values, bool isMap = false) {
form.redrawTimer.Start();
EditorWindow editor = new EditorWindow(names, types, values, isMap);
editor.ShowDialog();
form.redrawTimer.Stop();
if (editor.save) {
if (valueInHex) editor.ConvertValues(false);
return editor.values;
}
return null;
}
private EditorWindow(string[] values) {
this.values = values;
InitializeComponent();
checkBox.Checked = EditorWindow.valueInHex;
dataGridView1.SuspendLayout();
if (valueInHex) ConvertValues(true);
for (int i = 0; i < values.Length; i++) {
dataGridView1.Rows.Add(i.ToString(), "Int", values[i]);
}
dataGridView1.ResumeLayout();
}
public static string[] ShowEditor(DebugEditor form, string[] lvalues) {
form.redrawTimer.Start();
EditorWindow editor = new EditorWindow(lvalues);
editor.ShowDialog();
form.redrawTimer.Stop();
if (editor.save) {
if (valueInHex) editor.ConvertValues(false);
return editor.values;
}
return null;
}
private bool CheckInput(DataType type, string str) {
switch (type) {
case DataType.Int:
if (valueInHex) {
try {
Convert.ToInt32(str, 16);
return true;
} catch (Exception) {
return false;
}
}
int i;
return int.TryParse(str, out i);
case DataType.Float:
float f;
return float.TryParse(str, out f);
}
return true;
}
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) {
string str = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
if (str != null && CheckInput(((types != null) ? types[e.RowIndex] : DataType.Int), str))
values[e.RowIndex] = str;
else
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = values[e.RowIndex];
}
private void bCancel_Click(object sender, EventArgs e) {
Close();
}
private void bSave_Click(object sender, EventArgs e) {
save = true;
Close();
}
private void checkBox_Click(object sender, EventArgs e) {
valueInHex = checkBox.Checked;
ConvertValues(valueInHex);
for (int i = 0; i < values.Length; i++) {
dataGridView1.Rows[i].Cells[2].Value = values[i];
}
}
}
}
-38
View File
@@ -1,38 +0,0 @@
using System;
using System.Windows.Forms;
using System.IO;
namespace FalloutClient {
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args) {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (args.Length == 1 && args[0] == "-debugedit") {
Application.Run(new DebugEditor(new EditorConnection()));
} else {
MessageBox.Show("The debug editor can only be run from the game.\n" +
"Use the key assigned to the DebugEditorKey option in ddraw.ini to run the debugger.",
"sfall Debug Editor", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}
}
enum DataTypeSend {
SetGlobal = 0,
SetMapVar = 1,
RetrieveCritter = 2,
SetCritter = 3,
SetSGlobal = 4,
GetArray = 9,
SetArray = 10,
GetLocal = 11,
SetLocal = 12,
Exit = 254,
RedrawGame = 255
}
}
+8 -7
View File
@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -645,14 +645,14 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
@@ -664,11 +664,12 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
@@ -23,20 +23,17 @@
/// 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();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.bGlobals = new System.Windows.Forms.Button();
this.bMapVars = new System.Windows.Forms.Button();
this.bCritters = new System.Windows.Forms.Button();
this.bSGlobals = new System.Windows.Forms.Button();
this.bArrays = new System.Windows.Forms.Button();
this.Column0 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.bEdit = new System.Windows.Forms.Button();
this.redrawTimer = new System.Windows.Forms.Timer(this.components);
this.bCrittersLvar = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
@@ -44,38 +41,84 @@
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.AllowUserToResizeRows = false;
this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView1.ColumnHeadersHeight = 22;
this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column0,
this.Column1,
this.Column2,
this.Column3});
this.dataGridView1.Location = new System.Drawing.Point(12, 12);
this.dataGridView1.MultiSelect = false;
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersVisible = false;
this.dataGridView1.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView1.Size = new System.Drawing.Size(561, 354);
this.dataGridView1.Size = new System.Drawing.Size(444, 215);
this.dataGridView1.TabIndex = 0;
this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick);
this.dataGridView1.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEndEdit);
this.dataGridView1.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.dataGridView1_RowsAdded);
//
// bGlobals
//
this.bGlobals.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.bGlobals.Location = new System.Drawing.Point(12, 233);
this.bGlobals.Name = "bGlobals";
this.bGlobals.Size = new System.Drawing.Size(100, 23);
this.bGlobals.TabIndex = 1;
this.bGlobals.Text = "Globals";
this.bGlobals.UseVisualStyleBackColor = true;
this.bGlobals.Click += new System.EventHandler(this.bGlobals_Click);
//
// bMapVars
//
this.bMapVars.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.bMapVars.Location = new System.Drawing.Point(118, 233);
this.bMapVars.Name = "bMapVars";
this.bMapVars.Size = new System.Drawing.Size(100, 23);
this.bMapVars.TabIndex = 2;
this.bMapVars.Text = "Map variables";
this.bMapVars.UseVisualStyleBackColor = true;
this.bMapVars.Click += new System.EventHandler(this.bMapVars_Click);
//
// bCritters
//
this.bCritters.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.bCritters.Location = new System.Drawing.Point(118, 262);
this.bCritters.Name = "bCritters";
this.bCritters.Size = new System.Drawing.Size(100, 23);
this.bCritters.TabIndex = 3;
this.bCritters.Text = "Critters";
this.bCritters.UseVisualStyleBackColor = true;
this.bCritters.Click += new System.EventHandler(this.bCritters_Click);
//
// bSGlobals
//
this.bSGlobals.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.bSGlobals.Location = new System.Drawing.Point(225, 233);
this.bSGlobals.Name = "bSGlobals";
this.bSGlobals.Size = new System.Drawing.Size(100, 23);
this.bSGlobals.TabIndex = 4;
this.bSGlobals.Text = "sfall globals";
this.bSGlobals.UseVisualStyleBackColor = true;
this.bSGlobals.Click += new System.EventHandler(this.bSGlobals_Click);
//
// bArrays
//
this.bArrays.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.bArrays.Location = new System.Drawing.Point(12, 262);
this.bArrays.Name = "bArrays";
this.bArrays.Size = new System.Drawing.Size(100, 23);
this.bArrays.TabIndex = 5;
this.bArrays.Text = "sfall arrays";
this.bArrays.UseVisualStyleBackColor = true;
this.bArrays.Click += new System.EventHandler(this.bArrays_Click);
//
// Column0
//
this.Column0.HeaderText = "ID";
this.Column0.Name = "Column0";
this.Column0.ReadOnly = true;
this.Column0.Width = 50;
//
// Column1
//
this.Column1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Column1.HeaderText = "Name";
this.Column1.Name = "Column1";
this.Column1.ReadOnly = true;
@@ -90,65 +133,10 @@
this.Column3.HeaderText = "Value (Float)";
this.Column3.Name = "Column3";
//
// bGlobals
//
this.bGlobals.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.bGlobals.Location = new System.Drawing.Point(12, 372);
this.bGlobals.Name = "bGlobals";
this.bGlobals.Size = new System.Drawing.Size(100, 23);
this.bGlobals.TabIndex = 1;
this.bGlobals.Text = "Globals";
this.bGlobals.UseVisualStyleBackColor = true;
this.bGlobals.Click += new System.EventHandler(this.bGlobals_Click);
//
// bMapVars
//
this.bMapVars.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.bMapVars.Location = new System.Drawing.Point(118, 372);
this.bMapVars.Name = "bMapVars";
this.bMapVars.Size = new System.Drawing.Size(100, 23);
this.bMapVars.TabIndex = 2;
this.bMapVars.Text = "Map variables";
this.bMapVars.UseVisualStyleBackColor = true;
this.bMapVars.Click += new System.EventHandler(this.bMapVars_Click);
//
// bCritters
//
this.bCritters.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.bCritters.Location = new System.Drawing.Point(12, 401);
this.bCritters.Name = "bCritters";
this.bCritters.Size = new System.Drawing.Size(100, 23);
this.bCritters.TabIndex = 3;
this.bCritters.Text = "Critters";
this.bCritters.UseVisualStyleBackColor = true;
this.bCritters.Click += new System.EventHandler(this.bCritters_Click);
//
// bSGlobals
//
this.bSGlobals.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.bSGlobals.Location = new System.Drawing.Point(367, 372);
this.bSGlobals.Name = "bSGlobals";
this.bSGlobals.Size = new System.Drawing.Size(100, 23);
this.bSGlobals.TabIndex = 4;
this.bSGlobals.Text = "sfall globals";
this.bSGlobals.UseVisualStyleBackColor = true;
this.bSGlobals.Click += new System.EventHandler(this.bSGlobals_Click);
//
// bArrays
//
this.bArrays.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.bArrays.Location = new System.Drawing.Point(473, 372);
this.bArrays.Name = "bArrays";
this.bArrays.Size = new System.Drawing.Size(100, 23);
this.bArrays.TabIndex = 5;
this.bArrays.Text = "sfall arrays";
this.bArrays.UseVisualStyleBackColor = true;
this.bArrays.Click += new System.EventHandler(this.bArrays_Click);
//
// bEdit
//
this.bEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.bEdit.Location = new System.Drawing.Point(473, 401);
this.bEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.bEdit.Location = new System.Drawing.Point(225, 262);
this.bEdit.Name = "bEdit";
this.bEdit.Size = new System.Drawing.Size(100, 23);
this.bEdit.TabIndex = 6;
@@ -156,29 +144,11 @@
this.bEdit.UseVisualStyleBackColor = true;
this.bEdit.Click += new System.EventHandler(this.bEdit_Click);
//
// redrawTimer
//
this.redrawTimer.Interval = 200;
this.redrawTimer.Tick += new System.EventHandler(this.timer1_Tick);
//
// bCrittersLvar
//
this.bCrittersLvar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.bCrittersLvar.Enabled = false;
this.bCrittersLvar.Location = new System.Drawing.Point(118, 401);
this.bCrittersLvar.Name = "bCrittersLvar";
this.bCrittersLvar.Size = new System.Drawing.Size(100, 23);
this.bCrittersLvar.TabIndex = 7;
this.bCrittersLvar.Text = "Local variables";
this.bCrittersLvar.UseVisualStyleBackColor = true;
this.bCrittersLvar.Click += new System.EventHandler(this.bCrittersLvar_Click);
//
// DebugEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(585, 436);
this.Controls.Add(this.bCrittersLvar);
this.ClientSize = new System.Drawing.Size(468, 297);
this.Controls.Add(this.bEdit);
this.Controls.Add(this.bArrays);
this.Controls.Add(this.bSGlobals);
@@ -186,10 +156,8 @@
this.Controls.Add(this.bMapVars);
this.Controls.Add(this.bGlobals);
this.Controls.Add(this.dataGridView1);
this.MinimumSize = new System.Drawing.Size(450, 300);
this.Name = "DebugEditor";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "sfall Debug Editor";
this.Text = "DebugEditor";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DebugEditor_FormClosing);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
@@ -204,13 +172,11 @@
private System.Windows.Forms.Button bCritters;
private System.Windows.Forms.Button bSGlobals;
private System.Windows.Forms.Button bArrays;
private System.Windows.Forms.Button bEdit;
private System.Windows.Forms.DataGridViewTextBoxColumn Column0;
private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
internal System.Windows.Forms.Timer redrawTimer;
private System.Windows.Forms.Button bCrittersLvar;
private System.Windows.Forms.Button bEdit;
}
}
+300
View File
@@ -0,0 +1,300 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using File=System.IO.File;
using StreamReader=System.IO.StreamReader;
using MemoryStream=System.IO.MemoryStream;
using BinaryReader=System.IO.BinaryReader;
using BinaryWriter=System.IO.BinaryWriter;
namespace FalloutClient {
public partial class DebugEditor : Form {
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Explicit)]
private struct ByteConverter {
[System.Runtime.InteropServices.FieldOffset(0)]
private int i;
[System.Runtime.InteropServices.FieldOffset(0)]
private float f;
public int GetAsInt(float f) {
this.f=f;
return i;
}
public float GetAsFloat(int i) {
this.i=i;
return f;
}
public byte[] GetAsBytes(ulong ul) {
byte[] b=new byte[8];
for(int i=0;i<8;i++) b[i]=(byte)((ul&((ulong)0xff<<(i*8)))>>(i*8));
return b;
}
}
private static ByteConverter converter=new ByteConverter();
private enum Mode { Globals, MapVars, SGlobals, Arrays, Critters }
private readonly EditorConnection connection;
private Mode mode;
private readonly Dictionary<int, string> GlobNames=new Dictionary<int, string>();
private readonly Dictionary<uint, string> CritNames=new Dictionary<uint, string>();
private void Redraw() {
dataGridView1.SuspendLayout();
dataGridView1.Rows.Clear();
switch(mode) {
case Mode.Globals:
Column2.ReadOnly=false;
Column3.ReadOnly=false;
Column2.HeaderText="Value (Int)";
Column3.HeaderText="Value (Float)";
bEdit.Enabled=false;
for(int i=0;i<connection.Globals.Length;i++) {
string name=GlobNames.ContainsKey(i)?GlobNames[i]:"";
dataGridView1.Rows.Add(i, name, connection.Globals[i], converter.GetAsFloat(connection.Globals[i]));
}
break;
case Mode.MapVars:
Column2.ReadOnly=false;
Column3.ReadOnly=false;
Column2.HeaderText="Value (Int)";
Column3.HeaderText="Value (Float)";
bEdit.Enabled=false;
for(int i=0;i<connection.MapVars.Length;i++) {
dataGridView1.Rows.Add(i, "", connection.MapVars[i], converter.GetAsFloat(connection.MapVars[i]));
}
break;
case Mode.SGlobals:
Column2.ReadOnly=false;
Column3.ReadOnly=false;
Column2.HeaderText="Value (Int)";
Column3.HeaderText="Value (Float)";
bEdit.Enabled=false;
for(int i=0;i<connection.SGlobalKeys.Length;i++) {
string s=connection.SGlobalKeys[i]>0xffffffff?new string(System.Text.ASCIIEncoding.ASCII.GetChars(converter.GetAsBytes(connection.SGlobalKeys[i]))):("0x"+connection.SGlobalKeys[i].ToString("x"));
dataGridView1.Rows.Add(s, "", connection.sGlobals[i], converter.GetAsFloat(connection.sGlobals[i]));
}
break;
case Mode.Arrays:
Column2.ReadOnly=true;
Column3.ReadOnly=true;
Column2.HeaderText="Array length";
Column3.HeaderText="Element size";
bEdit.Enabled=true;
for(int i=0;i<connection.Arrays.Length;i++) {
dataGridView1.Rows.Add(connection.Arrays[i], "", connection.ArrayLengths[i], connection.ArrayDataSizes[i]);
}
break;
case Mode.Critters:
Column2.ReadOnly=true;
Column3.ReadOnly=true;
Column2.HeaderText="pid";
Column3.HeaderText="";
bEdit.Enabled=true;
for(int i=0;i<connection.Critters.Length;i++) {
uint modcrit=(connection.Critters[i]&0xfffff);
string name=CritNames.ContainsKey(modcrit)?CritNames[modcrit]:"";
dataGridView1.Rows.Add(i+1, name, connection.Critters[i].ToString("x"), "");
}
break;
}
dataGridView1.ResumeLayout();
}
internal DebugEditor(EditorConnection connection) {
InitializeComponent();
this.connection=connection;
mode=Mode.Globals;
if(File.Exists("globals.txt")) {
StreamReader sr=new StreamReader("globals.txt");
while(!sr.EndOfStream) {
string[] line=sr.ReadLine().Split(' ');
GlobNames[int.Parse(line[0])]=line[1];
}
sr.Close();
}
if(File.Exists("critters.txt")) {
StreamReader sr=new StreamReader("critters.txt");
while(!sr.EndOfStream) {
string line=sr.ReadLine();
CritNames[uint.Parse(line.Remove(line.IndexOf(' ')))]=line.Substring(line.IndexOf(' ')+1);
}
sr.Close();
}
Redraw();
}
private void DebugEditor_FormClosing(object sender, FormClosingEventArgs e) {
connection.WriteDataType(DataTypeSend.Exit);
connection.Close();
}
private void bGlobals_Click(object sender, EventArgs e) {
mode=Mode.Globals;
Redraw();
}
private void bMapVars_Click(object sender, EventArgs e) {
mode=Mode.MapVars;
Redraw();
}
private void bSGlobals_Click(object sender, EventArgs e) {
mode=Mode.SGlobals;
Redraw();
}
private void bArrays_Click(object sender, EventArgs e) {
mode=Mode.Arrays;
Redraw();
}
private void bCritters_Click(object sender, EventArgs e) {
mode=Mode.Critters;
Redraw();
}
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) {
int[] array=null;
DataTypeSend dts;
switch(mode) {
case Mode.Globals:
array=connection.Globals;
dts=DataTypeSend.SetGlobal;
break;
case Mode.MapVars:
array=connection.MapVars;
dts=DataTypeSend.SetMapVar;
break;
case Mode.SGlobals:
array=connection.sGlobals;
dts=DataTypeSend.SetSGlobal;
break;
default:
return;
}
if(e.ColumnIndex==2) {
int val;
if(!int.TryParse(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(), out val)) {
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value=array[e.RowIndex];
} else {
array[e.RowIndex]=val;
connection.WriteDataType(dts);
connection.WriteInt(e.RowIndex);
connection.WriteInt(val);
}
} else {
float val;
if(!float.TryParse(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(), out val)) {
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value=array[e.RowIndex];
} else {
array[e.RowIndex]=converter.GetAsInt(val);
connection.WriteDataType(dts);
connection.WriteInt(e.RowIndex);
connection.WriteInt(converter.GetAsInt(val));
}
}
}
private void bEdit_Click(object sender, EventArgs e) {
if(dataGridView1.SelectedRows.Count!=1) return;
int i=dataGridView1.SelectedRows[0].Index;
switch(mode) {
case Mode.Arrays: {
DataType[] types=new DataType[connection.ArrayLengths[i]];
string[] strings=new string[connection.ArrayLengths[i]];
connection.WriteDataType(DataTypeSend.GetArray);
connection.WriteInt(i);
for(int j=0;j<strings.Length;j++) types[j]=(DataType)connection.ReadInt();
byte[] buf=connection.ReadBytes(connection.ArrayLengths[i]*connection.ArrayDataSizes[i]);
MemoryStream ms=new MemoryStream(buf);
BinaryReader br=new BinaryReader(ms);
for(int j=0;j<strings.Length;j++) {
ms.Position=j*connection.ArrayDataSizes[i];
switch(types[j]) {
case DataType.Int:
strings[j]=br.ReadInt32().ToString();
break;
case DataType.Float:
strings[j]=br.ReadSingle().ToString();
break;
case DataType.String:
byte[] bytes=br.ReadBytes(connection.ArrayDataSizes[i]);
strings[j]=System.Text.Encoding.ASCII.GetString(bytes, 0, Array.IndexOf<byte>(bytes, 0));
break;
}
}
br.Close();
strings=EditorWindow.ShowEditor(null, types, strings);
if(strings!=null) {
connection.WriteDataType(DataTypeSend.SetArray);
connection.WriteInt(i);
ms=new MemoryStream(connection.ArrayLengths[i]*connection.ArrayDataSizes[i]);
BinaryWriter bw=new BinaryWriter(ms);
for(int j=0;j<strings.Length;j++) {
ms.Position=j*connection.ArrayDataSizes[i];
switch(types[j]) {
case DataType.Int:
bw.Write(int.Parse(strings[j]));
break;
case DataType.Float:
bw.Write(float.Parse(strings[j]));
break;
case DataType.String:
byte[] bytes=System.Text.Encoding.ASCII.GetBytes(strings[j]);
if(bytes.Length<connection.ArrayDataSizes[i]) bw.Write(bytes);
else bw.Write(bytes, 0, connection.ArrayDataSizes[i]-1);
bw.Write(0);
break;
}
}
connection.WriteBytes(ms.GetBuffer(), 0, connection.ArrayLengths[i]*connection.ArrayDataSizes[i]);
bw.Close();
}
}
break;
case Mode.Critters: {
DataType[] types=new DataType[29];
string[] strings=new string[29];
string[] names=new string[29];
connection.WriteDataType(DataTypeSend.RetrieveCritter);
connection.WriteInt(i);
BinaryReader br=new BinaryReader(new System.IO.MemoryStream(connection.ReadBytes(29*4)));
for(int j=0;j<29;j++) {
types[j]=DataType.Int;
strings[j]=br.ReadInt32().ToString();
names[j]="0x"+(j*4).ToString("x");
}
br.Close();
names[1]="Tile";
names[10]="Elevation";
names[11]="Inventory count";
names[13]="Inventory pointer";
names[16]="Current AP";
names[17]="Crippled limbs";
names[22]="HP";
names[23]="Rads";
names[24]="Poison";
names[25]="Proto ID";
strings=EditorWindow.ShowEditor(names, types, strings);
if(strings!=null) {
MemoryStream ms=new MemoryStream(29*4);
BinaryWriter bw=new BinaryWriter(ms);
for(int j=0;j<29;j++) bw.Write(int.Parse(strings[j]));
connection.WriteDataType(DataTypeSend.SetCritter);
connection.WriteInt(i);
connection.WriteBytes(ms.GetBuffer(), 0, 29*4);
bw.Close();
}
}
break;
}
}
}
}
@@ -129,7 +129,4 @@
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="redrawTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
@@ -3,9 +3,7 @@ using System.Net.Sockets;
using System.IO;
namespace FalloutClient {
class EditorConnection
{
class EditorConnection {
private TcpClient client;
private NetworkStream stream;
private BinaryReader br;
@@ -13,81 +11,73 @@ namespace FalloutClient {
public readonly int[] Globals;
public readonly int[] MapVars;
public readonly uint[,] Critters;
public readonly uint[] Critters;
public readonly ulong[] SGlobalKeys;
public readonly int[] sGlobals;
public readonly uint[] Arrays;
public readonly int[] ArrayLengths;
public readonly int[] ArrayFlag;
public readonly bool[] ArrayIsMap;
public readonly int[] ArrayDataSizes;
public EditorConnection() {
System.Threading.Thread.Sleep(1000);
client = new TcpClient("127.0.0.1", 4245);
stream = client.GetStream();
br = new BinaryReader(stream);
bw = new BinaryWriter(stream);
Globals = new int[br.ReadInt32()];
MapVars = new int[br.ReadInt32()];
SGlobalKeys = new ulong[br.ReadInt32()];
sGlobals = new int[SGlobalKeys.Length];
Arrays = new uint[br.ReadInt32()];
ArrayLengths = new int[Arrays.Length];
ArrayFlag = new int[Arrays.Length];
ArrayIsMap = new bool[Arrays.Length];
Critters = new uint[br.ReadInt32(), 2];
client=new TcpClient("127.0.0.1", 4245);
stream=client.GetStream();
br=new BinaryReader(stream);
bw=new BinaryWriter(stream);
Globals=new int[br.ReadInt32()];
MapVars=new int[br.ReadInt32()];
SGlobalKeys=new ulong[br.ReadInt32()];
sGlobals=new int[SGlobalKeys.Length];
Arrays=new uint[br.ReadInt32()];
ArrayLengths=new int[Arrays.Length];
ArrayDataSizes=new int[Arrays.Length];
Critters=new uint[br.ReadInt32()];
for (int i = 0; i < Globals.Length; i++) Globals[i] = br.ReadInt32();
for (int i = 0; i < MapVars.Length; i++) MapVars[i] = br.ReadInt32();
for (int i = 0; i < sGlobals.Length; i++) {
SGlobalKeys[i] = br.ReadUInt64();
sGlobals[i] = br.ReadInt32();
for(int i=0;i<Globals.Length;i++) Globals[i]=br.ReadInt32();
for(int i=0;i<MapVars.Length;i++) MapVars[i]=br.ReadInt32();
for(int i=0;i<sGlobals.Length;i++) {
SGlobalKeys[i]=br.ReadUInt64();
sGlobals[i]=br.ReadInt32();
br.ReadInt32();
}
for (int i = 0; i < Arrays.Length; i++) {
Arrays[i] = br.ReadUInt32();
ArrayIsMap[i] = (br.ReadInt32() != 0);
ArrayLengths[i] = br.ReadInt32();
ArrayFlag[i] = br.ReadInt32();
}
for (int i = 0; i < Critters.Length / 2; i++) {
Critters[i, 0] = br.ReadUInt32();
Critters[i, 1] = br.ReadUInt32();
for(int i=0;i<Arrays.Length;i++) {
Arrays[i]=br.ReadUInt32();
ArrayLengths[i]=br.ReadInt32();
ArrayDataSizes[i]=br.ReadInt32();
}
for(int i=0;i<Critters.Length;i++) Critters[i]=br.ReadUInt32();
}
public void Close() {
stream.Close();
client.Close();
stream = null;
client = null;
stream=null;
client=null;
}
public void WriteDataType(DataTypeSend type) {
stream.WriteByte((byte)type);
//bw.Write((byte)type);
}
public void WriteByte(byte b) { bw.Write(b); }
public void WriteInt16(short value) { bw.Write(value); }
public void WriteInt(int value) { bw.Write(value); }
public void WriteBytes(byte[] buf) { bw.Write(buf); }
public void WriteBytes(byte[] buf, int start, int len) {
bw.Write(buf, start, len);
}
public void Read(byte[] buffer) {
int upto = 0;
while (upto < buffer.Length) {
upto += stream.Read(buffer, upto, buffer.Length - upto);
int upto=0;
while(upto<buffer.Length) {
upto+=stream.Read(buffer, upto, buffer.Length-upto);
}
}
public void Read(byte[] buffer, int offset, int length) {
int upto = 0;
int upto=0;
//System.Diagnostics.Debug.WriteLine("Read - offset: "+offset+" length: "+length);
while (upto < length) {
upto += stream.Read(buffer, offset + upto, length - upto);
while(upto<length) {
upto+=stream.Read(buffer, offset+upto, length-upto);
}
}
public int ReadByte() {
@@ -29,14 +29,13 @@
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.checkBox = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// bSave
//
this.bSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.bSave.Location = new System.Drawing.Point(12, 336);
this.bSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.bSave.Location = new System.Drawing.Point(281, 265);
this.bSave.Name = "bSave";
this.bSave.Size = new System.Drawing.Size(75, 23);
this.bSave.TabIndex = 0;
@@ -47,7 +46,7 @@
// bCancel
//
this.bCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.bCancel.Location = new System.Drawing.Point(371, 336);
this.bCancel.Location = new System.Drawing.Point(200, 265);
this.bCancel.Name = "bCancel";
this.bCancel.Size = new System.Drawing.Size(75, 23);
this.bCancel.TabIndex = 1;
@@ -59,77 +58,49 @@
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.AllowUserToResizeRows = false;
this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView1.ColumnHeadersHeight = 22;
this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column1,
this.Column2,
this.Column3});
this.dataGridView1.Location = new System.Drawing.Point(12, 12);
this.dataGridView1.MultiSelect = false;
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersVisible = false;
this.dataGridView1.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
this.dataGridView1.Size = new System.Drawing.Size(434, 318);
this.dataGridView1.Size = new System.Drawing.Size(344, 247);
this.dataGridView1.TabIndex = 2;
this.dataGridView1.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEndEdit);
//
// Column1
//
this.Column1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.Column1.HeaderText = "Element";
this.Column1.HeaderText = "Name";
this.Column1.Name = "Column1";
this.Column1.ReadOnly = true;
this.Column1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Column2
//
this.Column2.HeaderText = "Type";
this.Column2.Name = "Column2";
this.Column2.ReadOnly = true;
this.Column2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.Column2.Width = 75;
//
// Column3
//
this.Column3.HeaderText = "Value";
this.Column3.Name = "Column3";
this.Column3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.Column3.Width = 150;
//
// checkBox
//
this.checkBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.checkBox.AutoSize = true;
this.checkBox.Location = new System.Drawing.Point(103, 341);
this.checkBox.Name = "checkBox";
this.checkBox.Size = new System.Drawing.Size(91, 17);
this.checkBox.TabIndex = 3;
this.checkBox.Text = "Values in Hex";
this.checkBox.UseVisualStyleBackColor = true;
this.checkBox.Click += new System.EventHandler(this.checkBox_Click);
//
// EditorWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(458, 371);
this.Controls.Add(this.checkBox);
this.ClientSize = new System.Drawing.Size(368, 300);
this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.bCancel);
this.Controls.Add(this.bSave);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.MinimumSize = new System.Drawing.Size(300, 200);
this.Name = "EditorWindow";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Edit Values";
this.Text = "EditorWindow";
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
@@ -141,6 +112,5 @@
private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
private System.Windows.Forms.CheckBox checkBox;
}
}
+56
View File
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace FalloutClient {
public enum DataType : int { None=0, Int=1, Float=2, String=3 }
public partial class EditorWindow : Form {
private readonly DataType[] types;
private readonly string[] values;
private bool save;
private EditorWindow(string[] names, DataType[] types, string[] values) {
this.types=types;
this.values=values;
InitializeComponent();
dataGridView1.SuspendLayout();
if(names==null) for(int i=0;i<types.Length;i++) dataGridView1.Rows.Add(i.ToString(), types[i].ToString(), values[i]);
else for(int i=0;i<types.Length;i++) dataGridView1.Rows.Add(names[i], types[i].ToString(), values[i]);
dataGridView1.ResumeLayout();
}
public static string[] ShowEditor(string[] names, DataType[] types, string[] values) {
EditorWindow editor=new EditorWindow(names, types, values);
editor.ShowDialog();
if(editor.save) return editor.values;
else return null;
}
private bool CheckInput(DataType type, string str) {
switch(type) {
case DataType.Int:
int i;
return int.TryParse(str, out i);
case DataType.Float:
float f;
return float.TryParse(str, out f);
}
return true;
}
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) {
string str=(string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
if(CheckInput(types[e.RowIndex], str)) values[e.RowIndex]=str;
else dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value=values[e.RowIndex];
}
private void bCancel_Click(object sender, EventArgs e) {
Close();
}
private void bSave_Click(object sender, EventArgs e) {
save=true;
Close();
}
}
}
@@ -9,28 +9,13 @@
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FalloutClient</RootNamespace>
<AssemblyName>FalloutDebug</AssemblyName>
<AssemblyName>FalloutClient</AssemblyName>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>false</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -42,14 +27,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@@ -79,18 +62,6 @@
<DependentUpon>EditorWindow.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
@@ -100,7 +71,6 @@
</Target>
-->
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
<PostBuildEvent>copy "$(TargetPath)" "C:\Games\Fallout2\$(TargetName)$(TargetExt)"</PostBuildEvent>
</PropertyGroup>
</Project>
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfallDebugEditor", "SfallDebugEditor.csproj", "{80ED0DCE-100E-4EC9-A79D-2FBFA4CAD1E3}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MPClient", "MPClient.csproj", "{80ED0DCE-100E-4EC9-A79D-2FBFA4CAD1E3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
+28
View File
@@ -0,0 +1,28 @@
using System;
using System.Windows.Forms;
using System.IO;
namespace FalloutClient {
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args) {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if(args.Length==1&&args[0]=="-debugedit") {
Application.Run(new DebugEditor(new EditorConnection()));
} else {
throw new Exception("Multiplayer is no longer supported");
}
}
}
enum DataTypeSend {
Mouse=0, LMouseDown=1, LMouseUp=2, RMouseDown=3, RMouseUp=4, TakeChar=5, ReleaseChar=6,
SetGlobal=0, SetMapVar=1, RetrieveCritter=2, SetCritter=3, SetSGlobal=4, GetArray=9, SetArray=10,
Exit=254
}
}

Some files were not shown because too many files have changed in this diff Show More