use new haxe for-in syntax

This commit is contained in:
lif 2020-04-17 21:48:02 -07:00
parent 4db2b31176
commit 04f4fa3ef1
15 changed files with 70 additions and 68 deletions

2
intra/new-for-syntax.sh Normal file
View File

@ -0,0 +1,2 @@
grep -Plr 'for\(([^= ]*)=([^;]*);\1<([^=;]*);\1\+\+\)' source/ | xargs sed -i 's#for(\([^= ]*\)=\([^;]*\);\1<\([^=;]*\);\1++)#for(\1 in \2...\3)#'
grep -Plr 'for\(var ([^=:]*):Int=([^;]*);\1<([^=;]*);\1\+\+\)' source/ | xargs sed -i 's#for(var \([^=:]*\):Int=\([^;]*\);\1<\([^=;]*\);\1++)#for(\1 in \2...\3)#'

View File

@ -1194,7 +1194,7 @@ class Intra extends FlxGame {
*/
if(FlxG.keys.justPressed("R")){
for(var y:Int=36;y<48;y++){
for(y in 36...48){
Registry.card_states[y]=1;
Registry.nr_growths++;
}
@ -1219,7 +1219,7 @@ class Intra extends FlxGame {
}
if(FlxG.keys.justPressed("S")){
for(var i:Int=11;i<=Registry.IDX_WHITE;i++){
for(i in 11...Registry.IDX_WHITE+1){
Registry.inventory[i]=true;
}
}
@ -1789,4 +1789,4 @@ class Intra extends FlxGame {
position_bars();
}
}
}

View File

@ -189,7 +189,7 @@ class Save {
if(ref[0]===false){
if(old.length<ref.length){
trace("Array with falses in save was shorter than in disk");
for(var j:Int=old.length;j<ref.length;j++){
for(j in old.length...ref.length){
old.push(false);
}
}

View File

@ -1,5 +1,5 @@
package data
{
package data ;
import helper.Cutscene;
import org.flixel.FlxG;
import org.flixel.FlxGroup;
@ -531,7 +531,7 @@ class SoundData
teleguy_down.loadEmbedded(embed_teleguy_down);
teleguy_up.loadEmbedded(embed_teleguy_up);
gasguy_shoot.loadEmbedded(embed_gasguy_shoot);
init_sound_group(gasguy_move, embed_gasguy_move)
init_sound_group(gasguy_move, embed_gasguy_move);
init_sound_group(rat_move, embed_rat_move);
sb_split.loadEmbedded(embed_sb_split);
@ -608,7 +608,7 @@ class SoundData
}
public function init_multi_sound_group(g:FlxGroup, sounds:Array, looped:Bool=false, volume:Float=1):Void {
for(var sound:Class in sounds){
for(sound in sounds){
var s:FlxSound=new FlxSound;
s.loadEmbedded(sound, looped, volume);
g.add(s);
@ -846,4 +846,4 @@ class SoundData
}
}
}
}

View File

@ -733,7 +733,7 @@ class TileData
curMapBuf.setTileProperties(20, FlxObject.NONE, TileData.conveyer);
curMapBuf.setTileProperties(21, FlxObject.ANY, null, null, 3);
curMapBuf.setTileProperties(32, FlxObject.NONE, TileData.spike, Player);
for(j in 36...=48){
for(j in 36...49){
curMapBuf.setTileProperties(j, FlxObject.NONE);
}
HOLE_INDICES.push(9);
@ -1141,7 +1141,7 @@ class TileData
} else if(p.cid==CLASS_ID.SILVERFISH){
if((p.y<ty + 4)&&(p.y + p.height>ty)&&
(p.x<tx + 6)&&(p.x + p.width>tx)){
p.xml.@alive="false";
p.xml.alive="false";
Registry.GRID_ENEMIES_DEAD++;
p.exists=false;
}
@ -1149,7 +1149,7 @@ class TileData
if((p.y<ty + 11)&&(p.y + p.height>ty)&&
(p.x<tx + 8)&&(p.x + p.width>tx)){
p.xml.@alive="false";
p.xml.alive="false";
Registry.GRID_ENEMIES_DEAD++;
p.exists=false;
}
@ -1161,7 +1161,7 @@ class TileData
p.velocity.y *=0.25;
if((p.y<ty + 4)&&(p.y + p.height>ty)&&
(p.x<tx + 6)&&(p.x + p.width>tx)){
p.xml.@alive="false";
p.xml.alive="false";
Registry.GRID_ENEMIES_DEAD++;
p.exists=false;
}

File diff suppressed because one or more lines are too long

View File

@ -122,7 +122,7 @@ class Achievements
if(Registry.inventory[Registry.IDX_JUMP])rate +=2;
for(i in 11...=Registry.IDX_WHITE){
for(i in 11...Registry.IDX_WHITE+1){
if(Registry.inventory[i]){
rate +=4;
}
@ -250,4 +250,4 @@ class Achievements
}
}
}

View File

@ -350,7 +350,7 @@ class Cutscene extends PushableFlxState
var tilemap:FlxTilemap=new FlxTilemap();
tilemap.loadMap(CSV, tileset, 16, 16);
var submap_data:Array<Dynamic>=new Array();
for(var i:Int=0;i<w*h;i++){
for(i in 0...w*h){
submap_data.push(tilemap.getTile(gx * 10 +(i % w), gy * 10 +(i / h)));
}
tilemap.destroy();

View File

@ -104,7 +104,7 @@ class ScreenFade
private function fx_rect(rate:Int):Int {
for(var i:Int=offset;i<offset + rate;i++){
for(i in offset...offset + rate){
for(j in 0...base.width){
base.setPixel32(j, i, 0xff000000);
}
@ -125,8 +125,8 @@ class ScreenFade
for(y in 0...height +=stride){
for(x in 0...width +=stride){
next_color=thing_to_draw.bitmapData.getPixel32(x,y);
for(var _x:Int=x;_x<x + stride;_x++){
for(var _y:Int=y;_y<y + stride;_y++){
for(_x in x...x + stride){
for(_y in y...y + stride){
thing_to_draw.bitmapData.setPixel32(_x, _y, next_color);
}
}
@ -152,8 +152,8 @@ class ScreenFade
for(y in 0...buf.height +=stride){
for(x in 0...buf.width +=stride){
next_color=buf.getPixel32(x,y);
for(var _x:Int=x;_x<x + stride;_x++){
for(var _y:Int=y;_y<y + stride;_y++){
for(_x in x...x + stride){
for(_y in y...y + stride){
buf.setPixel32(_x, _y, next_color);
}
}

View File

@ -153,7 +153,7 @@ class Save {
if(ref[0]===false){
if(old.length<ref.length){
trace("Array with falses in save was shorter than in disk");
for(var j:Int=old.length;j<ref.length;j++){
for(j in old.length...ref.length){
old.push(false);
}
}

View File

@ -1,5 +1,5 @@
package org.flixel
{
package org.flixel ;
import entity.player.Player;
import flash.geom.Point;
import global.Registry;
@ -45,4 +45,4 @@ class AnoSprite extends FlxSprite
super.destroy();
}
}
}

View File

@ -76,7 +76,7 @@ class FlxGradient
ratio.push(0);
for(var ri:Int=1;ri<colors.length - 1;ri++)
for(ri in 1...colors.length - 1)
{
ratio.push(ri * spread);
}

View File

@ -128,7 +128,7 @@ class PNGEncoder
var e:Int=png.position;
png.position=p;
c=0xffffffff;
for(var i:Int=0;i<(e-p);i++){
for(i in 0...(e-p)){
c=uint(crcTable[
(c ^ png.readUnsignedByte())&
uint(0xff)] ^ Int(c>>>8));

View File

@ -217,7 +217,7 @@ class MinimapState extends PushableFlxState
private function update_map():Void
{
for(var i:Int=0;i<minimap.widthInTiles * minimap.heightInTiles;i++){
for(i in 0...minimap.widthInTiles * minimap.heightInTiles){
if(1 !=visited[Registry.CURRENT_MAP_NAME][i]){
minimap.setTileByIndex(i, blank_tile_index, true);
}

View File

@ -520,7 +520,7 @@ class RoamState extends FlxState
var prev_len:Int=entities.length;
for(var grid:XML in xml){
if(load_all ||(parseInt(grid.@grid_x)==gx && parseInt(grid.@grid_y)==gy)){
for(var i:Int=0;i<grid.child("*").length();i++){
for(i in 0...grid.child("*").length()){
SpriteFactory.makeSprite(grid.child("*")[i], i, entities, entities, player, this, darkness);
if(entities.length !=prev_len){
while(prev_len<entities.length){