hedgewars/uScript.pas
changeset 12499 1b483882b60f
parent 12498 f3d6f1b0b59d
child 12541 e54039ea3934
equal deleted inserted replaced
12498:f3d6f1b0b59d 12499:1b483882b60f
  3013                 begin
  3013                 begin
  3014                     if (lastChar = '-') and (mybuf[i] = '-') then
  3014                     if (lastChar = '-') and (mybuf[i] = '-') then
  3015                         inComment := true
  3015                         inComment := true
  3016                     // gonna add any non-magic whitespace and skip - just to make comment avoidance easier
  3016                     // gonna add any non-magic whitespace and skip - just to make comment avoidance easier
  3017                     else if not inComment and (byte(mybuf[i]) > $20) and (byte(mybuf[i]) < $7F) and (mybuf[i]<>'-') then
  3017                     else if not inComment and (byte(mybuf[i]) > $20) and (byte(mybuf[i]) < $7F) and (mybuf[i]<>'-') then
  3018                         AddRandomness(byte(mybuf[i]));
  3018                         begin
       
  3019                         AddRandomness(byte(mybuf[i]));  // wish I had the seed...
       
  3020                         CheckSum := CheckSum xor GetRandom($FFFFFFFF);
       
  3021                         end;
  3019                     lastChar := mybuf[i];
  3022                     lastChar := mybuf[i];
  3020                     if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) then
  3023                     if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) then
  3021                         inComment := false 
  3024                         inComment := false 
  3022                 end;
  3025                 end;
  3023         end;
  3026         end;
  3032         begin
  3035         begin
  3033             for i:= 0 to sz^-1 do
  3036             for i:= 0 to sz^-1 do
  3034                 begin
  3037                 begin
  3035                     if not inComment and (mybuf[i] = '"') and (lastChar <> '\') then
  3038                     if not inComment and (mybuf[i] = '"') and (lastChar <> '\') then
  3036                         inQuote := not inQuote;
  3039                         inQuote := not inQuote;
  3037                     if (lastChar = '-') and (mybuf[i] = '-') then
  3040                     if not inQuote and (lastChar = '-') and (mybuf[i] = '-') then
  3038                         inComment := true;
  3041                         inComment := true;
  3039                     if not inComment and not inQuote then
  3042                     if not inComment and not inQuote then
  3040                        locSum := locSum xor (byte(mybuf[i]) shl (i mod 4));
  3043                        locSum := locSum xor (byte(mybuf[i]) shl (i mod 4));
  3041                     if not inComment and not inQuote and 
  3044                     if not inComment and not inQuote and 
  3042                         ((mybuf[i] = '(') or 
  3045                         ((mybuf[i] = '(') or 
  3090 physfsReaderSetBuffer(@buf);
  3093 physfsReaderSetBuffer(@buf);
  3091 if Pos('Locale/',s) <> 0 then
  3094 if Pos('Locale/',s) <> 0 then
  3092      ret:= lua_load(luaState, @ScriptLocaleReader, f, Str2PChar(s))
  3095      ret:= lua_load(luaState, @ScriptLocaleReader, f, Str2PChar(s))
  3093 else ret:= lua_load(luaState, @ScriptReader, f, Str2PChar(s));
  3096 else ret:= lua_load(luaState, @ScriptReader, f, Str2PChar(s));
  3094 pfsClose(f);
  3097 pfsClose(f);
  3095 CheckSum := CheckSum xor GetRandom($FFFFFFFF);
       
  3096 
  3098 
  3097 if ret <> 0 then
  3099 if ret <> 0 then
  3098     begin
  3100     begin
  3099     LuaError('Failed to load ' + name + '(error ' + IntToStr(ret) + ')');
  3101     LuaError('Failed to load ' + name + '(error ' + IntToStr(ret) + ')');
  3100     LuaError(lua_tostring(luaState, -1));
  3102     LuaError(lua_tostring(luaState, -1));