Conversation
Updated job experience calculation to award experience based on item materials for blacksmith, carpenter, and alchemist jobs. Added new configuration keys for specific material experience values in Configuracion.ini and adjusted ServerConfig.cls and Trabajo.bas to support the new logic.
Updated t_UserOBJ and related function parameters to use Long for amount/quantity fields, improving consistency and supporting larger values. Fixed ServerConfig to load job experience values from their specific keys instead of a shared one. Modified GiveExpWhileWorking to account for item quantity when calculating experience gains for blacksmith and carpenter jobs.
Potential effects and risks to review
Useful links to continue the review The commit comparison used for this analysis: amount field usages: https://github.com/search?q=repo%3Aao-org%2Fargentum-online-server+amount&type=code |
|
@morgolock revisar con ganas. |
morgolock
left a comment
There was a problem hiding this comment.
Muchos problemas a solucionar, requiere rework
| UserList(UserIndex).Counters.Trabajando = UserList(UserIndex).Counters.Trabajando + 1 | ||
| If IsFeatureEnabled("gain_exp_while_working") Then | ||
| Call GiveExpWhileWorking(UserIndex, UserList(UserIndex).invent.EquippedWorkingToolObjIndex, e_JobsTypes.Blacksmith) | ||
| Call GiveExpWhileWorking(UserIndex, MiObj.ObjIndex, e_JobsTypes.Blacksmith, MiObj.Amount) |
There was a problem hiding this comment.
Refactor this to pass MiObj by ref and Call GiveExpWhileWorking(UserIndex, MiObj, e_JobsTypes.Blacksmith)
| End Function | ||
|
|
||
| Public Function GiveExpWhileWorking(ByVal UserIndex As Integer, ByVal ItemIndex As Integer, ByVal JobType As Byte) | ||
| Public Function GiveExpWhileWorking(ByVal UserIndex As Integer, ByVal ItemIndex As Integer, ByVal JobType As Byte, Optional ByVal Quantity As Integer = 1) |
There was a problem hiding this comment.
Refactor this to GiveExpWhileWorking(ByVal UserIndex As Integer, obj as t_Obj, ByVal JobType As Byte)
- GiveExpWhileWorking signature and types: Quantity is a Long, and default type mismatch
You changed:
Public Function GiveExpWhileWorking(... Optional ByVal Quantity As Integer = 1)
But you’re passing MiObj.Amount which is now Long.
In VB6 this will coerce, but it’s still wrong-footed and can overflow if Amount > 32767.
Action: make it:
Optional ByVal Quantity As Long = 1
and keep tmpExp As Long (good change).
| Public Type t_UserOBJ | ||
| ObjIndex As Integer | ||
| amount As Integer | ||
| Amount As Long |
There was a problem hiding this comment.
- t_UserOBJ.amount As Integer → Amount As Long is a breaking structural change
Changing a UDT field type (and even just its name, though VB is case-insensitive) changes the binary layout of t_UserOBJ.
That can break anything that:
Get/Put’s inventory structs to disk (binary saves, charfiles, etc.)
Sends inventory structs over the network (packet layouts)
Copies memory blobs around (e.g., CopyMemory, RtlMoveMemory, custom serialization)
Even if you never serialize t_UserOBJ, a UDT size change can still break code that assumes offsets.
Action: search for any Get #, Put #, Len(t_UserOBJ), CopyMemory, or packet building that writes t_UserOBJ raw. If any exist, you need a migration/compat layer or keep stored format as Integer and clamp.
Also: Inventory stack sizes being Long is reasonable, but you should enforce caps anyway (anti-dupe / overflow / economy).
| End Function | ||
|
|
||
| Function QuitarObjetos(ByVal ItemIndex As Integer, ByVal cant As Integer, ByVal UserIndex As Integer, Optional ByVal ElementalTags As Long = e_ElementalTags.Normal) As Boolean | ||
| Function QuitarObjetos(ByVal ItemIndex As Integer, ByVal cant As Long, ByVal UserIndex As Integer, Optional ByVal ElementalTags As Long = e_ElementalTags.Normal) As Boolean |
There was a problem hiding this comment.
- QuitarObjetos and material removal types: mixed Long/Integer
You updated:
QuitarObjetos(... cant As Long ...)
But left:
CarpinteroQuitarMateriales(... CantidadElfica As Integer, CantidadPino As Integer)
If someone crafts in bulk and CantidadElfica or CantidadPino can exceed 32767, that’s a silent overflow risk.
Action: make all these quantities Long for consistency:
CantidadElfica As Long
CantidadPino As Long
(and any other “Cantidad*” used in bulk crafting paths)
| tmpExp = tmpExp + ObjData(ItemIndex).MaderaElfica * SvrConfig.GetValue("ElvenWoodCarpentryExp") * Quantity | ||
| End If | ||
| Case e_JobsTypes.Woodcutter | ||
| tmpExp = SvrConfig.GetValue("FellingExp") |
There was a problem hiding this comment.
- Duplicate Case e_JobsTypes.Woodcutter
You currently have Woodcutter twice:
Case e_JobsTypes.Woodcutter
tmpExp = ...
...
Case e_JobsTypes.Woodcutter
tmpExp = ...
Not harmful (first match wins), but it’s dead/duplicate code and can hide future edits.
Action: remove the duplicate case.
| If ObjData(ItemIndex).FlorRoja > 0 Then | ||
| tmpExp = tmpExp + ObjData(ItemIndex).FlorRoja * SvrConfig.GetValue("MixingExp") | ||
| End If | ||
| If ObjData(ItemIndex).FlorOceano > 0 Then | ||
| tmpExp = tmpExp + ObjData(ItemIndex).FlorRoja * SvrConfig.GetValue("MixingExp") | ||
| End If | ||
| If ObjData(ItemIndex).ColaDeZorro > 0 Then | ||
| tmpExp = tmpExp + ObjData(ItemIndex).FlorRoja * SvrConfig.GetValue("MixingExp") | ||
| End If | ||
| If ObjData(ItemIndex).Tuna > 0 Then | ||
| tmpExp = tmpExp + ObjData(ItemIndex).FlorRoja * SvrConfig.GetValue("MixingExp") | ||
| End If | ||
| If ObjData(ItemIndex).HongoDeLuz > 0 Then | ||
| tmpExp = tmpExp + ObjData(ItemIndex).FlorRoja * SvrConfig.GetValue("MixingExp") | ||
| End If | ||
| If ObjData(ItemIndex).SemillasPros > 0 Then | ||
| tmpExp = tmpExp + ObjData(ItemIndex).FlorRoja * SvrConfig.GetValue("MixingExp") | ||
| End If | ||
| If ObjData(ItemIndex).Cala > 0 Then | ||
| tmpExp = tmpExp + ObjData(ItemIndex).FlorRoja * SvrConfig.GetValue("MixingExp") | ||
| End If | ||
| Case Else |
There was a problem hiding this comment.
- Big logic bug in Alchemist EXP: copy/paste uses the wrong ingredient every time
You added:
If ObjData(ItemIndex).FlorOceano > 0 Then
tmpExp = tmpExp + ObjData(ItemIndex).FlorRoja * SvrConfig.GetValue("MixingExp")
End If
…and similarly for ColaDeZorro, Tuna, HongoDeLuz, SemillasPros, Cala: they all add FlorRoja.
That’s almost certainly a bug.
Fix: each branch should multiply its own field:
FlorOceano branch uses ObjData(ItemIndex).FlorOceano
ColaDeZorro uses ObjData(ItemIndex).ColaDeZorro
etc.
Also: you don’t apply * Quantity in the Alchemist case (you do for forging/carpentry). If bulk crafting is intended to scale EXP, you likely want * Quantity for Alchemist too.
-Added variables to change "per crafting material" exp bonus while manufacturing items
-Added quantity multiplier to manufacturing exp gain