2721 const call = 'GetAmmoName'; |
2721 const call = 'GetAmmoName'; |
2722 params = 'ammoType [, ignoreOverwrite ]'; |
2722 params = 'ammoType [, ignoreOverwrite ]'; |
2723 begin |
2723 begin |
2724 if CheckAndFetchParamCountRange(L, 1, 2, call, params, np) then |
2724 if CheckAndFetchParamCountRange(L, 1, 2, call, params, np) then |
2725 begin |
2725 begin |
2726 at:= LuaToAmmoTypeOrd(L, 1, call, params); |
2726 at:= LuaToAmmoTypeOrd(L, 1, call, params); |
2727 ignoreOverwrite := false; |
2727 ignoreOverwrite := false; |
2728 if np > 1 then |
2728 if np > 1 then |
2729 ignoreOverwrite := lua_toboolean(L, 2); |
2729 ignoreOverwrite := lua_toboolean(L, 2); |
2730 if at >= 0 then |
2730 if at >= 0 then |
2731 if (not ignoreOverwrite) and (length(trluaammo[Ammoz[TAmmoType(at)].NameId]) > 0) then |
2731 if (not ignoreOverwrite) and (length(trluaammo[Ammoz[TAmmoType(at)].NameId]) > 0) then |
2732 lua_pushstring(L, PChar(trluaammo[Ammoz[TAmmoType(at)].NameId])) |
2732 lua_pushstring(L, PChar(trluaammo[Ammoz[TAmmoType(at)].NameId])) |
2733 else |
2733 else |
2734 lua_pushstring(L, PChar(trammo[Ammoz[TAmmoType(at)].NameId])); |
2734 lua_pushstring(L, PChar(trammo[Ammoz[TAmmoType(at)].NameId])); |
2735 end |
2735 end |
3052 function ScriptReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; Cdecl; |
3052 function ScriptReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; Cdecl; |
3053 var mybuf: PChar; |
3053 var mybuf: PChar; |
3054 i: LongInt; |
3054 i: LongInt; |
3055 begin |
3055 begin |
3056 mybuf := physfsReader(L, f, sz); |
3056 mybuf := physfsReader(L, f, sz); |
3057 if (mybuf <> nil) and (sz^ > 0) then |
3057 if (mybuf <> nil) and ((sz^) > 0) then |
3058 begin |
3058 begin |
3059 for i:= 0 to sz^-1 do |
3059 for i:= 0 to sz^-1 do |
3060 begin |
3060 begin |
3061 if (lastChar = '-') and (mybuf[i] = '-') then |
3061 if (lastChar = '-') and (mybuf[i] = '-') then |
3062 inComment := true |
3062 inComment := true |
3066 AddRandomness(byte(mybuf[i])); // wish I had the seed... |
3066 AddRandomness(byte(mybuf[i])); // wish I had the seed... |
3067 CheckSum := CheckSum xor GetRandom($FFFFFFFF); |
3067 CheckSum := CheckSum xor GetRandom($FFFFFFFF); |
3068 end; |
3068 end; |
3069 lastChar := mybuf[i]; |
3069 lastChar := mybuf[i]; |
3070 if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) then |
3070 if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) then |
3071 inComment := false |
3071 inComment := false |
3072 end; |
3072 end; |
3073 end; |
3073 end; |
3074 ScriptReader:= mybuf |
3074 ScriptReader:= mybuf |
3075 end; |
3075 end; |
3076 function ScriptLocaleReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; Cdecl; |
3076 function ScriptLocaleReader(L: Plua_State; f: PFSFile; sz: Psize_t) : PChar; Cdecl; |
3077 var mybuf: PChar; |
3077 var mybuf: PChar; |
3078 i: LongInt; |
3078 i: LongInt; |
3079 begin |
3079 begin |
3080 mybuf := physfsReader(L, f, sz); |
3080 mybuf := physfsReader(L, f, sz); |
3081 if (mybuf <> nil) and (sz^ > 0) then |
3081 if (mybuf <> nil) and ((sz^) > 0) then |
3082 begin |
3082 begin |
3083 for i:= 0 to sz^-1 do |
3083 for i:= 0 to sz^-1 do |
3084 begin |
3084 begin |
3085 if not inComment and (mybuf[i] = '"') and (lastChar <> '\') then |
3085 if not inComment and (mybuf[i] = '"') and (lastChar <> '\') then |
3086 inQuote := not inQuote; |
3086 inQuote := not inQuote; |
3087 if not inQuote and (lastChar = '-') and (mybuf[i] = '-') then |
3087 if not inQuote and (lastChar = '-') and (mybuf[i] = '-') then |
3088 inComment := true; |
3088 inComment := true; |
3089 if not inComment and not inQuote then |
3089 if not inComment and (not inQuote) then |
3090 locSum := locSum xor (byte(mybuf[i]) shl (i mod 4)); |
3090 locSum := locSum xor (byte(mybuf[i]) shl (i mod 4)); |
3091 if not inComment and not inQuote and |
3091 if not inComment and (not inQuote) and |
3092 ((mybuf[i] = '(') or |
3092 ((mybuf[i] = '(') or |
3093 (mybuf[i] = ')') or |
3093 (mybuf[i] = ')') or |
3094 (mybuf[i] = '+') or |
3094 (mybuf[i] = '+') or |
3095 (mybuf[i] = '#') or |
3095 (mybuf[i] = '#') or |
3096 (braceCount > 2) or |
3096 (braceCount > 2) or |
3097 (wordCount > 6)) then |
3097 (wordCount > 6)) then |
3098 CheckSum := locSum; |
3098 CheckSum := locSum; |
3099 if not inComment and not inQuote and ((mybuf[i] = '{') or (mybuf[i] = '}')) then |
3099 if not inComment and (not inQuote) and ((mybuf[i] = '{') or (mybuf[i] = '}')) then |
3100 inc(braceCount); |
3100 inc(braceCount); |
3101 if not inComment and not inQuote and |
3101 if not inComment and (not inQuote) and |
3102 (((byte(mybuf[i]) > $40) and (byte(mybuf[i]) < $5B)) or |
3102 (((byte(mybuf[i]) > $40) and (byte(mybuf[i]) < $5B)) or |
3103 ((byte(mybuf[i]) > $60) and (byte(mybuf[i]) < $7B)) or |
3103 ((byte(mybuf[i]) > $60) and (byte(mybuf[i]) < $7B)) or |
3104 ((byte(mybuf[i]) >= $30) and (byte(mybuf[i]) < $3A))) then |
3104 ((byte(mybuf[i]) >= $30) and (byte(mybuf[i]) < $3A))) then |
3105 inc(wordCount); |
3105 inc(wordCount); |
3106 lastChar := mybuf[i]; |
3106 lastChar := mybuf[i]; |
3107 if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) then |
3107 if (byte(mybuf[i]) = $0D) or (byte(mybuf[i]) = $0A) then |
3108 inComment := false |
3108 inComment := false |
3109 end; |
3109 end; |
3110 end; |
3110 end; |
3111 ScriptLocaleReader:= mybuf |
3111 ScriptLocaleReader:= mybuf |
3112 end; |
3112 end; |
3113 // ⭒⭐⭒✨⭐⭒✨⭐☆✨⭐✨✧✨☆✨✧✨☆⭒✨☆⭐⭒☆✧✨⭒✨⭐✧⭒☆⭒✧☆✨✧⭐☆✨☆✧⭒✨✧⭒☆⭐☆✧ |
3113 // ⭒⭐⭒✨⭐⭒✨⭐☆✨⭐✨✧✨☆✨✧✨☆⭒✨☆⭐⭒☆✧✨⭒✨⭐✧⭒☆⭒✧☆✨✧⭐☆✨☆✧⭒✨✧⭒☆⭐☆✧ |