Code Monkey home page Code Monkey logo

pjass's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pjass's Issues

Precedence of comparing operations

function foo takes nothing returns nothing
    local boolean b = 5 > 4 == 5 < 7
endfunction

This code produces error:
image

Actually, at first < and > are evaluated and then ==.


function foo takes nothing returns nothing
    local boolean a = 1 != 2 != false
endfunction

Error:
image

This once correctly evaluates to true.

There can be other issues related to precedence in comparisons.

Stdin processing

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).

Map protection: mixed CR and LF against editing

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

Scripts.zip


What to do:

  1. Find out the exact limit where this begins to cause problems (after pasting the above code in CR mode)
  2. If possible make pjass warn about mixed CR & LF in a file. Not CRLF but separately used CR and LF. A general once per file warning or if (1) is found an exact error message too. Ah I remember there was a problem with warnings vs errors right? :)

Wrong report of symbol multiply defined for AI scripts

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.

Reject CR line endings in Jass files

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.