301 Days

A year of gamedev experiments.

Day 59 - Concerned

| Comments

In which we explore our fears of code-database disagreement.

So here’s the issue: Back when it was available, there was a database backup bundled with the server source code. I’ve been working with that database so far, with great success. But there’s also a set of SQL scripts with the server source, which one would hope to be authoritative.

Tale of two Players

There’s not a lot of agreement between the existing database table (left) and the contents of the Player.sql script (right):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
[account],                              [Account],                      
[accountID],                            [AccountID],                
[age],                                  [Age],                      
[alignment],                          | [Align],                
[ancestor],                           | [Anonymous],                    
[ancestorID],                         <
[bankGold],                             [BankGold],                 
[birthday],                             [Birthday],
                                      > [Blind],
                                      > [Bow],
                                      > [BreatheWater],
                                      > [CharClass], 
                                      > [CharClassFull],                
[charisma],                             [Charisma],                 
[classFullName],                      | [ClassID],              
[classType],                          <
[confRoom],                             [ConfRoom],                 
[constitution],                         [Constitution],             
[currentKarma],                       | [CurPos],
[dead],                               | [Dagger],
[deleteDate],                         | [DexAdd],
[dexterity],                            [Dexterity],
[dexterityAdd],                       <
[dirPointer],                           [DirPointer],
                                      > [Echo],
                                      > [Encumb],
[exp],                                  [Exp],
[facet],                              | [FeatherFall],
[fighterSpecialization],              | [FighterSpecial],
                                      > [Flail],
[floating],                             [Floating],
[gender],                               [gender],
                                      > [Halberd],
[hits],                                 [Hits],
[hitsAdjustment],                     <
[hitsDoctored],                       <
[hitsMax],                              [HitsMax],
                                      > [ImpImmortal],
[ImpLevel],                             [ImpLevel],
[intelligence],                         [Intelligence],
                                      > [IsDead],
                                      > [IsHidden],
                                      > [IsInvisible],
[land],                                 [Land],
[lastOnline],                         | [LastSave],
[level],                                [Level],
[lifetimeKarma],                      | [LHItemAttuned],
[lifetimeMarks],                      | [LHItemID],
                                      > [Mace],
                                      > [Magic],
[mana],                                 [Mana],
[manaAdjustment],                     <
[manaMax],                              [ManaMax],
[map],                                  [Map],
[name],                                 [Name], 
[notes],                              | [NightVision],
[numDeaths],                            [NumDeaths],
[numKills],                             [NumKills],
[playerID],                             [PlayerID],
[playersFlagged],                     | [Poisoned],
[playersKilled],                      | [protocol],
[pvpDeaths],                          <
[pvpKills],                           <
[race],                                 [Race], 
                                      > [Rapier],
                                      > [RHItemAttuned], 
                                      > [RHItemID],
[roundsPlayed],                         [RoundsPlayed],
                                      > [SavedHitsMax],
                                      > [SavedManaMax],
                                      > [ShowTitle],
                                      > [Shuriken],
                                      > [Staff],
[stamina],                              [Stamina],
[staminaAdjustment],                  <
[stamLeft],                             [StamLeft],
                                      > [StrAdd],
[strength],                             [Strength],
[strengthAdd],                        <
[stunned],                              [Stunned],
[UW_hitsAdjustment],                  | [Sword],
[UW_hitsMax],                         | [Thievery],
[UW_intestines],                      | [Threestaff],
[UW_liver],                           | [TimeOut],
[UW_lungs],                           | [trainedBow],
[UW_manaAdjustment],                  | [trainedDagger],
[UW_manaMax],                         | [trainedFlail],
[UW_staminaAdjustment],               | [trainedHalberd],
[UW_staminaMax],                      | [trainedMace],
[UW_stomach],                         | [trainedMagic],
[visualKey],                          | [trainedRapier],
                                      > [trainedShuriken],
                                      > [trainedStaff],
                                      > [trainedSword],
                                      > [trainedThievery],
                                      > [trainedThreestaff],
                                      > [trainedTwoHanded],
                                      > [trainedUnarmed],
                                      > [Twohanded],
                                      > [Unarmed],
[wisdom],                               [Wisdom],
[xCord],                                [XCord],
[yCord],                                [YCord],
[zCord]                               <

I have the feeling that the SQL script is either historical or prescriptive, and doesn’t match the existing code; a few searches should help.

Does the code refer to UW_intestines? Yes, it’s the source of UW_hasIntestines in the PC class, used in the Underworld:

DragonsSpine/GameSystems/Commands/Command.cslink
4942
4943
4944
4945
if (chr.InUnderworld)
{
    if (chr.UW_hasIntestines) { chr.WriteToDisplay("You have your intestines."); }
    else { chr.WriteToDisplay("You do not have your intestines."); }

Does the code refer to trainedShuriken? Yes, but from the PlayerSkills table and not Player.

Does the code refer to fighterSpecialization or FighterSpecial? fighterSpecialization.

Conclusion: I should place my trust in DAL/DBPlayer.cs and the existing database, not Player.SQL. Good to know.

But… expect us?

And yet the server code is looking for an anonymous field in Player, which appears to actually exist in the PlayerSettings table. Mark it @bug, give a descriptive comment, and move on.

Bugs

Wrapping legacy code in tests always leads to a quandary: what do we do with the bugs that we find in the existing code?

On the one hand, we don’t want to constantly stop to fix them; we’re trying to move forward, not work on the legacy code. We should write the test for the way it should work, tag it as an expected failure, and move on.

On the other hand, we shouldn’t leave portions of the code untested. We should either fix the bug or write the tests to expect the broken behavior.

Pragmatism: To maintain testing momentum, tag and move on. Every so often (let’s say five days), comb through and try to apply a bunch of the easy fixes at once. Any bug that can’t be fixed in less than a day gets marked Expected Behavior and becomes a high-priority Feature Request on the new code.


Short day today. More substantive entry tomorrow.


Comments