@@ -123,6 +123,57 @@ void ValidateForOG()
123123 return ;
124124 }
125125
126+ // split the CurrentFile path on "opengraphics" folder
127+ var dir = Path . GetRelativePath ( Model . Settings . ObjDataDirectory , CurrentFile . FileName ) ;
128+ var parentDirName = Path . GetFileName ( Path . GetDirectoryName ( CurrentFile . FileName ) ) ;
129+
130+ var expectedDatName = $ "OG{ parentDirName } .dat";
131+ // handle 8 char length requirements
132+ if ( expectedDatName . Length > 8 )
133+ {
134+ var baseName = parentDirName ;
135+
136+ // strip off any trailing digits
137+ var letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" . ToCharArray ( ) ;
138+ var lastLetter = parentDirName . LastIndexOfAny ( letters ) ;
139+
140+ var suffixDigits = string . Empty ;
141+ var baseNameCharsToKeep = Math . Min ( baseName . Length , 6 ) ;
142+ if ( lastLetter >= 0 ) // if there are digits on the end, split them off to shorten the letter part of the name instead
143+ {
144+ var firstNumber = lastLetter + 1 ;
145+ baseName = parentDirName [ ..firstNumber ] ;
146+ suffixDigits = parentDirName [ firstNumber ..] ;
147+ baseNameCharsToKeep = Math . Min ( baseName . Length , 6 - suffixDigits . Length ) ;
148+ }
149+
150+ expectedDatName = $ "OG{ baseName [ ..baseNameCharsToKeep ] } { suffixDigits } ";
151+ if ( expectedDatName . Length > 8 )
152+ {
153+ // uhoh
154+ validationErrors . Add ( $ "✖ Expected name has more than 8 characters -> this is a bug, please report this to LeftofZen on discord or as an issue in the ObjectEditor repo") ;
155+ }
156+ }
157+
158+ // DAT name is NOT prefixed by OG_
159+ if ( CurrentObject . DatInfo . S5Header . Name != expectedDatName )
160+ {
161+ validationErrors . Add ( $ "✖ Internal header name is not correct. Expected=\" { expectedDatName } \" Actual=\" { CurrentObject . DatInfo . S5Header . Name } \" ") ;
162+ }
163+
164+ var expectedFilename = $ "OG_{ parentDirName } .dat";
165+ var actualFilename = Path . GetFileName ( CurrentFile . FileName ) ;
166+ if ( expectedFilename != actualFilename )
167+ {
168+ validationErrors . Add ( $ "✖ Filename not correct. Expected=\" { expectedFilename } \" Actual=\" { actualFilename } \" ") ;
169+ }
170+
171+ // DAT name is NOT prefixed by OG_
172+ if ( CurrentObject . DatInfo . S5Header . Name . Contains ( '_' ) )
173+ {
174+ validationErrors . Add ( "✖ Internal header name should not contain an underscore" ) ;
175+ }
176+
126177 // DAT name is prefixed by OG
127178 if ( ! CurrentObject . DatInfo . S5Header . Name . StartsWith ( "OG" ) )
128179 {
0 commit comments