lep / pjass Goto Github PK
View Code? Open in Web Editor NEWThe famous jass syntax checker.
License: BSD 2-Clause "Simplified" License
The famous jass syntax checker.
License: BSD 2-Clause "Simplified" License
function foo takes nothing returns nothing
local boolean b = 5 > 4 == 5 < 7
endfunction
Actually, at first <
and >
are evaluated and then ==
.
function foo takes nothing returns nothing
local boolean a = 1 != 2 != false
endfunction
This once correctly evaluates to true
.
There can be other issues related to precedence in comparisons.
I have tested the modulo operator in 1.27 and it's definitely breaking the script:
// OK
function hexadecimalNumber takes nothing returns nothing
local integer i = 10
endfunction
vs
// script doesnt load
function hexadecimalNumber takes nothing returns nothing
local integer i = 10 % 4
endfunction
Is it possible to process multiple files via stdin? Tried concatenating common.j + '\n' + blizzard.j but does not seem to be working (trying to parse wa3map.j from a map with a custom blizzard.j without having to dump the blizzard.j file to disk).
I found why you couldn't modify the map before the map has used MIXED line endings, some CR lines, some are LF lines. Because rawcodes sometimes contained LF, you can't just convert the whole file's line endings. But if there's a CR line too long it will crash the game/script. Notepad++ detected the file as CR.
I think you can circumvent the detection (LF is preferred, but CRLF works too) if you replace the CR line endings in globals block at the beginning with LF -- notepad++: search and replace & replace in selection only & extended: search\r
replace:\n
Now for the pjass: #6 - there I tested converting the whole file to \r
and it just crashed the game.
In current case the map protection interchangeably used \r
and \n
for lines. On one hand \r
apparently counts as a line separator for the interpreter, so you can have a two statements with line1\rline2\n
. At the same time, the protection used \n
too and thus avoided crashing the game like in #6 (too long \r
line)
I wanted to document it in some capacity first and foremost. Notepad++ is troublesome if it detects the file as CR because then you can't paste any long code into the map because it will produce a "long CR line" (and in the end cheaters are still not stopped by that...)
pjass does not report any errors, technically it's correct. The game is alright with that. But I think there's a different limit similar to #6 where pjass didn't report me any errors yet but the game parsed the Jass wrongly.
6/22 12:23:21.585 Opening map - C:/Users/shiny/Documents/Warcraft III/Maps/Jassdoc/UpgradeRPG-UnitTest/Upgrade_RPG_7.0G_Reporged Eng-inst.w3x
6/22 12:23:22.326 Map contains invalid Jass scripts that couldn't be compiled by war3, file: war3map.j @ 3378, error: encountered undeclared identifier 'r' on line 3378
This error happened right after I added the following code right after "endglobals" in CR mode using Notepad++:
function CreateUnitLogging takes player p, integer rawcode, real x, real y, real face returns unit
local unit u
local integer createdId
local string unitModel
local string funcCallString
set u = CreateUnit(p,rawcode,x,y,face)
set createdId = GetUnitTypeId(u)
set funcCallString = "call CreateUnit("+ I2S(GetPlayerId(p)) +","+ I2S(rawcode) +","+R2S(x)+","+R2S(y)+","+R2S(face)+")"
// patch 1.31.0.11889
set unitModel = BlzGetUnitStringField(u, ConvertUnitStringField ('umdl'))
call BJDebugMsg(funcCallString + " & model: '" + unitModel + "'")
if rawcode != createdId then
call BJDebugMsg("MISMATCH!!! last unit has id : " + I2S(createdId))
endif
// this leaks because we cannot clear and return u at the same time without a global or another function
return u
endfunction
I will attach the map's blizzard.j and war3map.j (MPQ:scripts/ folder) as compressed zip. Looks like the protection is easy to encounter, at least two versions of Upgrade RPG (Korean) have it. The blizzard.j file is based on 1.24+ version, it has some additions. The Reporged version doesn't need Dz API or anything of that kind and runs on 1.36.2
Upgrade_RPG_7.0G_Reporged Eng.w3x
What to do:
Pjass considers unary + to number as a syntax error, although it works in the game
local real time = LSReal("Time", + .05)
https://github.com/Luashine/wc3-test-maps/tree/master/variable-length-crash
In Jass, variable length of exactly 3959 or above will crash old versions of the game when loading "war3map.j". This is true for locals and globals.
Edit:
Appears to have been fixed in Reforged (1.33.0.19203). I didn't check which version.
Both war3map.j and the map are included here.
Currently: no warning, no error.
It reports Symbol multiply defined for all functions in separate AI scripts and functions which I copied from Blizzard.j into my custom common.ai. AI scripts and common.ai should be handled separately by default. common.ai and AI scripts only can use symbols from common.j and not blizzard.j or other AI scripts.
I didn't record it, but I think the crash and error message was exactly the same as in #5 if you put a "mac-style" CR war3map.j file in your map. This leaves us with the only valid line endings being \r\n
and \n
Tested 1.27 and Reforged 1.33.0 (Ref doesn't outright crash but at the very least doesn't load the script too)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.