TShock/TShock — Issue #345: Null Entries in tshock.sqlite Causes NRE
Author: HySpeed
Created: 2012-02-03 03:38:28+00:00
State: open

I manually created region using the SQLite Database Browser, which created this SQL row (exported to .sql for this document):
INSERT INTO Regions VALUES(3185,401,34,56,'BaseA085',888947085,NULL,1,NULL,'Admin');

Upon loading this database into TShock, it put this entry in the log file:
2012-02-02 22:15:24 - RegionManager: ERROR: System.NullReferenceException: Object reference not set to an instance of an object.
at TShockAPI.DB.RegionManager.ReloadAllRegions()

A correct SQL row would appear like this (exported to .sql):
INSERT INTO Regions VALUES(3185,401,34,56,'BaseA085',888947085,'',1,'','Admin');

I realize you probably don't get a lot of users manually creating database rows.
But I know from my experience that this has bitten me - the database doesn't have a default value of 'empty string', so it puts null. I suggest adding a null check to string values when reading from the db and if null, set to an empty string.

I did the same thing with Advanced Warpplates. I plan to send a similar note to DarkunderdoG.

Thanks