equal
deleted
inserted
replaced
3602 if (mybuf <> nil) and ((sz^) > 0) then |
3602 if (mybuf <> nil) and ((sz^) > 0) then |
3603 begin |
3603 begin |
3604 for i:= 0 to sz^-1 do |
3604 for i:= 0 to sz^-1 do |
3605 begin |
3605 begin |
3606 if (lastChar = '-') and (mybuf[i] = '-') then |
3606 if (lastChar = '-') and (mybuf[i] = '-') then |
3607 inComment := false // FIXME - set to false because lua considers --[====[ ]=====] Non-comment stuff to be sensible |
3607 inComment := true |
3608 // gonna add any non-magic whitespace and skip - just to make comment avoidance easier |
|
3609 else if not inComment and (byte(mybuf[i]) > $20) and (byte(mybuf[i]) < $7F) and (mybuf[i]<>'-') then |
3608 else if not inComment and (byte(mybuf[i]) > $20) and (byte(mybuf[i]) < $7F) and (mybuf[i]<>'-') then |
3610 begin |
3609 begin |
3611 AddRandomness(byte(mybuf[i])); // wish I had the seed... |
3610 AddRandomness(byte(mybuf[i])); // wish I had the seed... |
3612 CheckSum := CheckSum xor GetRandom($FFFFFFFF); |
3611 CheckSum := CheckSum xor GetRandom($FFFFFFFF); |
3613 end; |
3612 end; |
3614 lastChar := mybuf[i]; |
3613 lastChar := mybuf[i]; |
3615 if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) then |
3614 // lua apparently allows -- [===============[ as a valid block comment start. |
|
3615 // I can't be bothered to check for that nonsense. Will allow limited single line without [ |
|
3616 if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) or mybuf[i] = '[' then |
3616 inComment := false |
3617 inComment := false |
3617 end; |
3618 end; |
3618 end; |
3619 end; |
3619 ScriptReader:= mybuf |
3620 ScriptReader:= mybuf |
3620 end; |
3621 end; |
3647 (((byte(mybuf[i]) > $40) and (byte(mybuf[i]) < $5B)) or |
3648 (((byte(mybuf[i]) > $40) and (byte(mybuf[i]) < $5B)) or |
3648 ((byte(mybuf[i]) > $60) and (byte(mybuf[i]) < $7B)) or |
3649 ((byte(mybuf[i]) > $60) and (byte(mybuf[i]) < $7B)) or |
3649 ((byte(mybuf[i]) >= $30) and (byte(mybuf[i]) < $3A))) then |
3650 ((byte(mybuf[i]) >= $30) and (byte(mybuf[i]) < $3A))) then |
3650 inc(wordCount); |
3651 inc(wordCount); |
3651 lastChar := mybuf[i]; |
3652 lastChar := mybuf[i]; |
3652 if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) then |
3653 // this allows at least supporting the commented strings at end of line with lua script names |
|
3654 if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) or mybuf[i] = '[' then |
3653 inComment := false |
3655 inComment := false |
3654 end; |
3656 end; |
3655 end; |
3657 end; |
3656 ScriptLocaleReader:= mybuf |
3658 ScriptLocaleReader:= mybuf |
3657 end; |
3659 end; |
3688 |
3690 |
3689 physfsReaderSetBuffer(@buf); |
3691 physfsReaderSetBuffer(@buf); |
3690 if (Pos('Locale/',s) <> 0) or (s = 'Scripts/OfficialChallengeHashes.lua') then |
3692 if (Pos('Locale/',s) <> 0) or (s = 'Scripts/OfficialChallengeHashes.lua') then |
3691 ret:= lua_load(luaState, @ScriptLocaleReader, f, Str2PChar(s)) |
3693 ret:= lua_load(luaState, @ScriptLocaleReader, f, Str2PChar(s)) |
3692 else |
3694 else |
3693 begin |
3695 begin |
3694 SetRandomSeed(cSeed,true); |
3696 SetRandomSeed(cSeed,true); |
3695 ret:= lua_load(luaState, @ScriptReader, f, Str2PChar(s)) |
3697 ret:= lua_load(luaState, @ScriptReader, f, Str2PChar(s)) |
3696 end; |
3698 end; |
3697 pfsClose(f); |
3699 pfsClose(f); |
3698 |
3700 |
3699 if ret <> 0 then |
3701 if ret <> 0 then |
3700 begin |
3702 begin |
3701 LuaError('Failed to load ' + name + '(error ' + IntToStr(ret) + ')'); |
3703 LuaError('Failed to load ' + name + '(error ' + IntToStr(ret) + ')'); |