• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Is it nessesary to defined all elemenets of array?

Status
Not open for further replies.
Level 2
Joined
Sep 17, 2014
Messages
11
Hey guys! I am new to Jass but bofore codding in C++ so i think that understand jass code enough for modify my map because there are not difficult modifications at all that i want.

First question: I have array and i put value to him not successively. I mean that i fill up him depending on situations, so i can set his element with index 5 (or differenent) but not set elements before him(1,2,3,4). Is it bad or memmory leaks or something? By the way i need to do this that way because i need to get value by key and in C++ i would use map but here i chose indexes of array. I think now u understand why i need this and what elements can be chaotically located at the array. Therefore i ask about leaks and else.

Second question(not necessery): Now i write my code in JassCraft with editing war3map.j file after extraction from map via MPQMaster. But how can i write jass code in worl editor? Because i tired to put war3map.j back to map and then launch wc3(if already launched also ensure that game not started or selected in map list with modified map) when i want to test my changes. That's why i want to write jass code in world editor and just press one button when i want to look my changes.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
It would be easier if you show us how you are doing it. This link will show you how to post. http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/how-easily-post-triggers-163285/

It sounds like you are trying something like this though.

JASS:
// IntegerArray[0] // Never set
// IntegerArray[1] // Never set
// IntegerArray[2] // Never set
// IntegerArray[3] // Never set
// IntegerArray[4] // Never set
set IntegerArray[5] = 5 // set this to value.

If you mean the above where index 5 is set but the others are not then no you do not have to initialize the other indexes to a value. It does not cause a leak.

A leak is when something in memory is lost and can't be retrieved to be disposed of.

You should take a look at my 2 tutorials to get a good basis of efficient GUI coding. ( a lot of it will relate to jass) Then look at how to code efficient jass through my GUI to efficient jass tutorial.
Links are below in my sig.
 
Level 2
Joined
Sep 17, 2014
Messages
11
Thx.
You should take a look at my 2 tutorials to get a good basis of efficient GUI coding. ( a lot of it will relate to jass) Then look at how to code efficient jass through my GUI to efficient jass tutorial.
Links are below in my sig.
Now i havn't enough time and just do fast modify on other map. But i hate to code like this when i don't know language at a good level or at least some basics. So i agree with u and i hope that later do this because have plans for 2-3 maps.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
Ok and good luck. I'll give you some down and dirty better coding advises.

Get rid of the BJs. Blizzard functions / red text.
If you can reduce the amount of nested loops / ITEs / unit groups / anything else nested.
Anything used twice or more should be stored in a variable. Triggering unit and stuff like that. Makes coding faster, easier to read, easier to edit.
Local and Globals that are not used need to be destroyed. Example: call DestroyGroup() (this is for a unit group.)
Local and Global variables need to be nulled after they are destroyed ( if they can be destroyed). Only ones to not null are reals, integers, players, strings.

I believe I hit on most of the coding that should try to be done.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
1. Does not matter. Arrays in Wc3 are always from 0 to 8k. They are initialized with the default value, 0 in case of integer. Though it may be better to keep track what indexes you are using. Maps may be better realized via hashtable.

2. In the trigger editor of the World Editor you work in pages listed on the left side. The root at the top contains a header and the other pages each form an entry for the .wtg/.wct files. To convert a page to jass, go >Edit >Convert to custom text. When you save, all trigger pages, the header and additional generated stuff is merged to build the new war3map.j.
 
Status
Not open for further replies.
Top