Skip to content
21 changes: 0 additions & 21 deletions BackEnd/BackEnd.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<FileUpgradeFlags>40</FileUpgradeFlags>
<UpgradeBackupLocation>J:\JA2 1.13 SVN\xml-editor-vb\Backup\BackEnd\</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down Expand Up @@ -70,23 +69,6 @@
<LastGenOutput>Application.Designer.vb</LastGenOutput>
</None>
</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>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
Expand All @@ -97,7 +79,4 @@
<PackageReference Include="Microsoft.Windows.Compatibility" Version="9.0.0" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions BackEnd/Data Access/TableComments.vb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Option Strict On
Option Explicit On

Imports System.Data
Imports System.Runtime.CompilerServices

Expand Down
3 changes: 3 additions & 0 deletions BackEnd/Data Access/Tables.vb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Option Strict On
Option Explicit On

Public Class Tables
Public Const Sounds As String = "SOUND"
Public Const BurstSounds As String = "BURSTSOUND"
Expand Down
3 changes: 3 additions & 0 deletions BackEnd/Data Access/Tables/AutoIncrementTable.vb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Option Strict On
Option Explicit On

Imports System.Data

Public Class AutoIncrementTable
Expand Down
11 changes: 8 additions & 3 deletions BackEnd/Data Access/Tables/ControlTable.vb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Imports System.Xml
Option Strict On
Option Explicit On

Imports System.Xml
Imports System.IO
Imports System.Data

Expand Down Expand Up @@ -42,8 +45,10 @@ Public Class ControlTable

Protected Overridable Sub LoadControlData(ByVal fileName As String, ByVal filePath As String)
Dim xmldoc As New XmlDocument()
Dim fs As New FileStream(filePath, FileMode.Open, FileAccess.Read)
xmldoc.Load(fs)

Using fs As New FileStream(filePath, FileMode.Open, FileAccess.Read)
xmldoc.Load(fs)
End Using

Dim xmlnode As XmlNode = xmldoc.GetElementsByTagName("INVENTORYLIST").Item(0)
Dim xmlParentNode As XmlNodeList
Expand Down
98 changes: 37 additions & 61 deletions BackEnd/Data Access/Tables/DefaultTable.vb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Option Strict On
Option Explicit On

Imports System.Data
Imports System.IO

Expand All @@ -7,6 +10,24 @@ Public Class DefaultTable
Protected _table As DataTable
Protected WithEvents _dm As DataManager

' Dictionary mapping file names to table names for special cases
Private Shared ReadOnly FileNameToTableNameMap As New Dictionary(Of String, String) From {
{"Inventory\EnemyGunChoices.xml", "ENEMYGUNCHOICESDEFAULT"},
{"Inventory\GunChoices_Enemy_Admin.xml", "ENEMYGUNCHOICESADMIN"},
{"Inventory\GunChoices_Enemy_Regular.xml", "ENEMYGUNCHOICESREGULAR"},
{"Inventory\GunChoices_Enemy_Elite.xml", "ENEMYGUNCHOICESELITE"},
{"Inventory\GunChoices_Militia_Green.xml", "MILITIAGUNCHOICESGREEN"},
{"Inventory\GunChoices_Militia_Regular.xml", "MILITIAGUNCHOICESREGULAR"},
{"Inventory\GunChoices_Militia_Elite.xml", "MILITIAGUNCHOICESELITE"},
{"Inventory\EnemyItemChoices.xml", "ENEMYITEMCHOICESDEFAULT"},
{"Inventory\ItemChoices_Enemy_Admin.xml", "ENEMYITEMCHOICESADMIN"},
{"Inventory\ItemChoices_Enemy_Regular.xml", "ENEMYITEMCHOICESREGULAR"},
{"Inventory\ItemChoices_Enemy_Elite.xml", "ENEMYITEMCHOICESELITE"},
{"Inventory\ItemChoices_Militia_Green.xml", "MILITIAITEMCHOICESGREEN"},
{"Inventory\ItemChoices_Militia_Regular.xml", "MILITIAITEMCHOICESREGULAR"},
{"Inventory\ItemChoices_Militia_Elite.xml", "MILITIAITEMCHOICESELITE"}
}

Public Sub New(ByVal table As DataTable, ByVal manager As DataManager)
_table = table
_dm = manager
Expand All @@ -27,6 +48,15 @@ Public Class DefaultTable
Return filePath
End Function

''' <summary>
''' Applies table name mapping based on file name if it exists in the dictionary
''' </summary>
Private Sub ApplyTableNameMapping(fileName As String)
If FileNameToTableNameMap.ContainsKey(fileName) Then
_table.TableName = FileNameToTableNameMap(fileName)
End If
End Sub

Public Overridable Sub LoadData()
Const Temp As String = "temp"

Expand All @@ -45,35 +75,7 @@ Public Class DefaultTable
_table.TableName() = "ENEMYITEMCHOICES"
End If
_table.ReadXml(filePath)
If fileName = "Inventory\EnemyGunChoices.xml" Then
_table.TableName = "ENEMYGUNCHOICESDEFAULT"
ElseIf fileName = "Inventory\GunChoices_Enemy_Admin.xml" Then
_table.TableName = "ENEMYGUNCHOICESADMIN"
ElseIf fileName = "Inventory\GunChoices_Enemy_Regular.xml" Then
_table.TableName = "ENEMYGUNCHOICESREGULAR"
ElseIf fileName = "Inventory\GunChoices_Enemy_Elite.xml" Then
_table.TableName = "ENEMYGUNCHOICESELITE"
ElseIf fileName = "Inventory\GunChoices_Militia_Green.xml" Then
_table.TableName = "MILITIAGUNCHOICESGREEN"
ElseIf fileName = "Inventory\GunChoices_Militia_Regular.xml" Then
_table.TableName = "MILITIAGUNCHOICESREGULAR"
ElseIf fileName = "Inventory\GunChoices_Militia_Elite.xml" Then
_table.TableName = "MILITIAGUNCHOICESELITE"
ElseIf fileName = "Inventory\EnemyItemChoices.xml" Then
_table.TableName = "ENEMYITEMCHOICESDEFAULT"
ElseIf fileName = "Inventory\ItemChoices_Enemy_Admin.xml" Then
_table.TableName = "ENEMYITEMCHOICESADMIN"
ElseIf fileName = "Inventory\ItemChoices_Enemy_Regular.xml" Then
_table.TableName = "ENEMYITEMCHOICESREGULAR"
ElseIf fileName = "Inventory\ItemChoices_Enemy_Elite.xml" Then
_table.TableName = "ENEMYITEMCHOICESELITE"
ElseIf fileName = "Inventory\ItemChoices_Militia_Green.xml" Then
_table.TableName = "MILITIAITEMCHOICESGREEN"
ElseIf fileName = "Inventory\ItemChoices_Militia_Regular.xml" Then
_table.TableName = "MILITIAITEMCHOICESREGULAR"
ElseIf fileName = "Inventory\ItemChoices_Militia_Elite.xml" Then
_table.TableName = "MILITIAITEMCHOICESELITE"
End If
ApplyTableNameMapping(fileName)
Else
Dim tableName As String = _table.TableName
For Each t In _table.DataSet.Tables
Expand Down Expand Up @@ -104,35 +106,7 @@ Public Class DefaultTable
_table.TableName() = "ENEMYITEMCHOICES"
End If
SaveData(_table)
If fileName = "Inventory\EnemyGunChoices.xml" Then
_table.TableName = "ENEMYGUNCHOICESDEFAULT"
ElseIf fileName = "Inventory\GunChoices_Enemy_Admin.xml" Then
_table.TableName = "ENEMYGUNCHOICESADMIN"
ElseIf fileName = "Inventory\GunChoices_Enemy_Regular.xml" Then
_table.TableName = "ENEMYGUNCHOICESREGULAR"
ElseIf fileName = "Inventory\GunChoices_Enemy_Elite.xml" Then
_table.TableName = "ENEMYGUNCHOICESELITE"
ElseIf fileName = "Inventory\GunChoices_Militia_Green.xml" Then
_table.TableName = "MILITIAGUNCHOICESGREEN"
ElseIf fileName = "Inventory\GunChoices_Militia_Regular.xml" Then
_table.TableName = "MILITIAGUNCHOICESREGULAR"
ElseIf fileName = "Inventory\GunChoices_Militia_Elite.xml" Then
_table.TableName = "MILITIAGUNCHOICESELITE"
ElseIf fileName = "Inventory\EnemyItemChoices.xml" Then
_table.TableName = "ENEMYITEMCHOICESDEFAULT"
ElseIf fileName = "Inventory\ItemChoices_Enemy_Admin.xml" Then
_table.TableName = "ENEMYITEMCHOICESADMIN"
ElseIf fileName = "Inventory\ItemChoices_Enemy_Regular.xml" Then
_table.TableName = "ENEMYITEMCHOICESREGULAR"
ElseIf fileName = "Inventory\ItemChoices_Enemy_Elite.xml" Then
_table.TableName = "ENEMYITEMCHOICESELITE"
ElseIf fileName = "Inventory\ItemChoices_Militia_Green.xml" Then
_table.TableName = "MILITIAITEMCHOICESGREEN"
ElseIf fileName = "Inventory\ItemChoices_Militia_Regular.xml" Then
_table.TableName = "MILITIAITEMCHOICESREGULAR"
ElseIf fileName = "Inventory\ItemChoices_Militia_Elite.xml" Then
_table.TableName = "MILITIAITEMCHOICESELITE"
End If
ApplyTableNameMapping(fileName)
End Sub

Protected Overridable Sub SaveData(ByVal table As DataTable)
Expand Down Expand Up @@ -284,8 +258,6 @@ Public Class DefaultTable
xw.WriteWhitespace(vbLf)
xw.Close()
view.Dispose()

'table.AcceptChanges()
End Sub

'this just works on single pk tables for now
Expand Down Expand Up @@ -346,8 +318,12 @@ Public Class DefaultTable
If canAddRow Then
Try
row.Table.Rows.Add(dupeRow)
Catch ex As ConstraintException
' Row already exists with this primary key, skip silently
ErrorHandler.LogError("Failed to add duplicate row", ex)
Catch ex As Exception

ErrorHandler.LogError("Unexpected error adding duplicate row", ex)
Throw
End Try
End If

Expand Down
3 changes: 3 additions & 0 deletions BackEnd/Data Access/Tables/DuplicateEntryTable.vb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Option Strict On
Option Explicit On

Imports System.Data

'for incompatible attachments and compatible face items
Expand Down
9 changes: 3 additions & 6 deletions BackEnd/Data Access/Tables/EnemyItemTable.vb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Option Strict On
Option Explicit On

Imports System.Data

Public Class EnemyItemTable
Expand Down Expand Up @@ -63,12 +66,6 @@ Public Class EnemyItemTable
Exit For
End If
Next
'row.ItemArray = ammoTable.Rows.Contains(rowindex)

'row.ItemArray = ammoTable.Rows(rowindex).ItemArray
'row("uiIndex") = 19
'_table.Rows.Add(row)
'ammoTable.Rows.RemoveAt(0)
End If
End Sub
End Class
5 changes: 4 additions & 1 deletion BackEnd/Data Access/Tables/InventoryTable.vb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Imports System.Data
Option Strict On
Option Explicit On

Imports System.Data
Imports System.Xml

Public Class InventoryTable
Expand Down
5 changes: 4 additions & 1 deletion BackEnd/Data Access/Tables/IteTable.vb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Imports System.Data
Option Strict On
Option Explicit On

Imports System.Data

Public Class IteTable
Inherits DefaultTable
Expand Down
30 changes: 7 additions & 23 deletions BackEnd/Data Access/Tables/ItemTable.vb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Option Strict On
Option Explicit On

Imports System.Xml
Imports System.IO
Imports System.Data
Expand Down Expand Up @@ -291,23 +294,7 @@ Public Class ItemTable
End Sub

Public Overrides Sub DeleteRow(ByVal key As Decimal)
'Dim row As DataRow = _table.Rows.Find(key)
MyBase.DeleteRow(key)
''MM: no longer needed due to nothing items being added automatically on save
'Dim nothingRow As DataRow = tbl.Rows.Find(0)
'If row IsNot Nothing Then
' Dim maxID = tbl.Compute("MAX(" & tbl.PrimaryKey(0).ColumnName & ")", Nothing)
' If row(Tables.Items.Fields.ID) = maxID Then 'if this is the last record, then we can delete it
'row.Delete()
' Else 'otherwise, we need to turn this into a nothing item,
''because JA2 will stop looking for items once it hits this one's zero value itemclass
'For Each c As DataColumn In tbl.Columns
' If Not c.ReadOnly AndAlso c IsNot tbl.PrimaryKey(0) Then row(c) = nothingRow(c)
'Next
'row(Tables.Items.Fields.ItemClass) = ItemClass.None
'row(Tables.Items.Fields.Description) = "Index " & row(Tables.Items.Fields.ID)
' End If
'End If
End Sub

Public Overrides Sub LoadData()
Expand All @@ -332,9 +319,11 @@ Public Class ItemTable
Dim a As Integer
Dim da, aap As Integer
Dim uicomments As Integer = 0
Dim fs As New FileStream(filePath, FileMode.Open, FileAccess.Read)

xmldoc.Load(fs)
Using fs As New FileStream(filePath, FileMode.Open, FileAccess.Read)
xmldoc.Load(fs)
End Using

xmlnode = xmldoc.GetElementsByTagName("ITEMLIST").Item(0)
For i = 0 To xmlnode.ChildNodes.Count - 1
If xmlnode.ChildNodes.Item(i).Name = "#comment" Then
Expand Down Expand Up @@ -399,8 +388,6 @@ Public Class ItemTable
Next
_table.Rows(rowIndex).EndEdit()
Next
fs.Close()
fs.Dispose()
End Sub

Protected Overrides Sub WriteXml(ByVal table As DataTable, ByVal fileName As String)
Expand Down Expand Up @@ -616,8 +603,6 @@ Public Class ItemTable
CopyExtraRow(Tables.Sounds, newRow, sourceRow, Tables.Weapons.Name & Tables.Weapons.Fields.LockNLoadSound, sourceDB)
CopyExtraRow(Tables.Sounds, newRow, sourceRow, Tables.Weapons.Name & Tables.Weapons.Fields.ReloadSound, sourceDB)
Case ItemClass.LBE
'lbes
'CopyExtraRow(Tables.Silhouettes, newRow, sourceRow, Tables.LoadBearingEquipment.Name & Tables.LoadBearingEquipment.Fields.Silhouette, sourceDB)
CopyExtraRow(Tables.LbeClasses, newRow, sourceRow, Tables.LoadBearingEquipment.Name & Tables.LoadBearingEquipment.Fields.LbeClass, sourceDB)
End Select

Expand All @@ -629,7 +614,6 @@ Public Class ItemTable

If row IsNot Nothing Then
Dim extraRow As DataRow = _dm.Database.CopyRows(tableName, New DataRow() {row}, sourceDB, False)
'newRow(fieldName) = extraRow(_dm.Database.Table(tableName).PrimaryKey(0))
End If
End Sub

Expand Down
11 changes: 8 additions & 3 deletions BackEnd/Data Access/Tables/ItemTransformationTable.vb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Imports System.Xml
Option Strict On
Option Explicit On

Imports System.Xml
Imports System.IO
Imports System.Data

Expand Down Expand Up @@ -28,9 +31,11 @@ Public Class ItemTransformationTable
Dim x As Integer
Dim da As Integer
Dim uiComments As Integer = 0
Dim fs As New FileStream(filePath, FileMode.Open, FileAccess.Read)

xmldoc.Load(fs)
Using fs As New FileStream(filePath, FileMode.Open, FileAccess.Read)
xmldoc.Load(fs)
End Using

xmlnode = xmldoc.GetElementsByTagName("TRANSFORMATIONS_LIST").Item(0)
For i = 0 To xmlnode.ChildNodes.Count - 1
If xmlnode.ChildNodes.Item(i).Name = "#comment" Then
Expand Down
Loading