Advertisement
Guest User

q3 shader debugger, checks for bracket mismatches

a guest
Dec 11th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'quake 3 arena shader debugger by rene breitinger, cc licensed 2016'
  2.  
  3. #Lang "qb"
  4. Option Explicit
  5.  
  6. Const shaderfile = "repak-c.shader"
  7.  
  8. Dim brackets As Integer
  9. Dim inline As String
  10. Dim filehandle As Integer
  11. Dim Lnum As Long
  12.  
  13. filehandle = Freefile
  14.  
  15. Open shaderfile For Input As #filehandle
  16.  
  17.     Do Until Eof( filehandle )
  18.         lnum = lnum  + 1
  19.        
  20.         Line Input #filehandle, inline
  21.  
  22.         'check if all brackets were closed before a new shader starts'
  23.         If Left$( lcase$( inline ), 1 ) = "textures/"  And brackets > 0 Then  Goto abnormalexit
  24.        
  25.         'check opening brackets'
  26.         If Instr( 1, inline, "{" ) <> 0 And brackets <= 2 Then brackets = brackets + 1  
  27.        
  28.         'check closing brackets'
  29.         If Instr (1, inline, "}" ) <> 0 And brackets > 0  Then brackets = brackets - 1
  30.        
  31.         'check invalid bracket num'
  32.         If brackets < 0 Or brackets > 2 Then Goto abnormalexit
  33.     Loop
  34.  
  35. Close #filehandle
  36.  
  37. Print "all shaders parsed; no bracket mismatches found!"
  38. Sleep
  39. End
  40.  
  41. abnormalexit:
  42. Close #filehandle
  43. Print "error in line "; lnum ,  inline
  44. Sleep
  45. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement