From 8bff28790791f36c47525d7456a551f605e32315 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 20 Feb 2021 16:01:39 -0800 Subject: [PATCH] Rename edentity to customentities This fixes the fact that the name of the singular type is plural, but the name of the plural array is singular. Which has always annoyed me, too. Also this makes it more clear that custom entities don't have much to do with the editor. --- desktop_version/src/CustomLevels.cpp | 60 ++--- desktop_version/src/CustomLevels.h | 2 +- desktop_version/src/Editor.cpp | 350 +++++++++++++-------------- desktop_version/src/Map.cpp | 8 +- desktop_version/src/main.cpp | 2 +- 5 files changed, 211 insertions(+), 211 deletions(-) diff --git a/desktop_version/src/CustomLevels.cpp b/desktop_version/src/CustomLevels.cpp index 0aaa4615..f9c02bc2 100644 --- a/desktop_version/src/CustomLevels.cpp +++ b/desktop_version/src/CustomLevels.cpp @@ -290,7 +290,7 @@ void customlevelclass::reset(void) levmusic=0; - edentity.clear(); + customentities.clear(); levmusic=0; for (int j = 0; j < maxheight; j++) @@ -850,10 +850,10 @@ void customlevelclass::findstartpoint(void) //Ok! Scan the room for the closest checkpoint int testeditor=-1; //First up; is there a start point on this screen? - for(size_t i=0; iQueryIntAttribute("p5", &entity.p5); edEntityEl->QueryIntAttribute("p6", &entity.p6); - edentity.push_back(entity); + customentities.push_back(entity); } } @@ -1347,19 +1347,19 @@ bool customlevelclass::save(std::string& _path) msg = xml::update_element_delete_contents(data, "edEntities"); - for(size_t i = 0; i < edentity.size(); i++) + for(size_t i = 0; i < customentities.size(); i++) { tinyxml2::XMLElement *edentityElement = doc.NewElement( "edentity" ); - edentityElement->SetAttribute( "x", edentity[i].x); - edentityElement->SetAttribute( "y", edentity[i].y); - edentityElement->SetAttribute( "t", edentity[i].t); - edentityElement->SetAttribute( "p1", edentity[i].p1); - edentityElement->SetAttribute( "p2", edentity[i].p2); - edentityElement->SetAttribute( "p3", edentity[i].p3); - edentityElement->SetAttribute( "p4", edentity[i].p4); - edentityElement->SetAttribute( "p5", edentity[i].p5); - edentityElement->SetAttribute( "p6", edentity[i].p6); - edentityElement->LinkEndChild( doc.NewText( edentity[i].scriptname.c_str() )) ; + edentityElement->SetAttribute( "x", customentities[i].x); + edentityElement->SetAttribute( "y", customentities[i].y); + edentityElement->SetAttribute( "t", customentities[i].t); + edentityElement->SetAttribute( "p1", customentities[i].p1); + edentityElement->SetAttribute( "p2", customentities[i].p2); + edentityElement->SetAttribute( "p3", customentities[i].p3); + edentityElement->SetAttribute( "p4", customentities[i].p4); + edentityElement->SetAttribute( "p5", customentities[i].p5); + edentityElement->SetAttribute( "p6", customentities[i].p6); + edentityElement->LinkEndChild( doc.NewText( customentities[i].scriptname.c_str() )) ; msg->LinkEndChild( edentityElement ); } @@ -1747,9 +1747,9 @@ Uint32 customlevelclass::getonewaycol(void) int customlevelclass::numtrinkets(void) { int temp = 0; - for (size_t i = 0; i < edentity.size(); i++) + for (size_t i = 0; i < customentities.size(); i++) { - if (edentity[i].t == 9) + if (customentities[i].t == 9) { temp++; } @@ -1760,9 +1760,9 @@ int customlevelclass::numtrinkets(void) int customlevelclass::numcrewmates(void) { int temp = 0; - for (size_t i = 0; i < edentity.size(); i++) + for (size_t i = 0; i < customentities.size(); i++) { - if (edentity[i].t == 15) + if (customentities[i].t == 15) { temp++; } diff --git a/desktop_version/src/CustomLevels.h b/desktop_version/src/CustomLevels.h index 33367094..c3b9ea8d 100644 --- a/desktop_version/src/CustomLevels.h +++ b/desktop_version/src/CustomLevels.h @@ -61,7 +61,7 @@ struct LevelMetaData }; -extern std::vector edentity; +extern std::vector customentities; class EditorData { diff --git a/desktop_version/src/Editor.cpp b/desktop_version/src/Editor.cpp index 5219a31b..32f6cfaf 100644 --- a/desktop_version/src/Editor.cpp +++ b/desktop_version/src/Editor.cpp @@ -258,19 +258,19 @@ static void addedentity( int xp, int yp, int tp, int p1 = 0, int p2 = 0, int p3 entity.p6=p6; entity.scriptname=""; - edentity.push_back(entity); + customentities.push_back(entity); } static void removeedentity( int t ) { - edentity.erase(edentity.begin() + t); + customentities.erase(customentities.begin() + t); } static int edentat( int xp, int yp ) { - for(size_t i=0; i= 0; i--) + for (int i = customentities.size() - 1; i >= 0; i--) { point tpoint; SDL_Rect drawRect; //if() on screen - if(edentity[i].x / 40 == ed.levx && edentity[i].y / 30 == ed.levy) + if(customentities[i].x / 40 == ed.levx && customentities[i].y / 30 == ed.levy) { - switch(edentity[i].t) + switch(customentities[i].t) { case 1: //Entities if (custom_gray) { graphics.setcol(18); ed.entcolreal = graphics.ct.colour; } - graphics.drawsprite((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),ed.getenemyframe(room->enemytype),ed.entcolreal); - if(edentity[i].p1==0) graphics.Print((edentity[i].x*8)- (ed.levx*40*8)+4,(edentity[i].y*8)- (ed.levy*30*8)+4, "V", 255, 255, 255 - help.glow, false); - if(edentity[i].p1==1) graphics.Print((edentity[i].x*8)- (ed.levx*40*8)+4,(edentity[i].y*8)- (ed.levy*30*8)+4, "^", 255, 255, 255 - help.glow, false); - if(edentity[i].p1==2) graphics.Print((edentity[i].x*8)- (ed.levx*40*8)+4,(edentity[i].y*8)- (ed.levy*30*8)+4, "<", 255, 255, 255 - help.glow, false); - if(edentity[i].p1==3) graphics.Print((edentity[i].x*8)- (ed.levx*40*8)+4,(edentity[i].y*8)- (ed.levy*30*8)+4, ">", 255, 255, 255 - help.glow, false); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),16,16,graphics.getBGR(255,164,255)); + graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),ed.getenemyframe(room->enemytype),ed.entcolreal); + if(customentities[i].p1==0) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+4,(customentities[i].y*8)- (ed.levy*30*8)+4, "V", 255, 255, 255 - help.glow, false); + if(customentities[i].p1==1) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+4,(customentities[i].y*8)- (ed.levy*30*8)+4, "^", 255, 255, 255 - help.glow, false); + if(customentities[i].p1==2) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+4,(customentities[i].y*8)- (ed.levy*30*8)+4, "<", 255, 255, 255 - help.glow, false); + if(customentities[i].p1==3) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+4,(customentities[i].y*8)- (ed.levy*30*8)+4, ">", 255, 255, 255 - help.glow, false); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,16,graphics.getBGR(255,164,255)); break; case 2: //Threadmills & platforms if (!INBOUNDS_VEC(obj.customplatformtile, graphics.entcolours)) { continue; } - tpoint.x = (edentity[i].x*8)- (ed.levx*40*8); - tpoint.y = (edentity[i].y*8)- (ed.levy*30*8); + tpoint.x = (customentities[i].x*8)- (ed.levx*40*8); + tpoint.y = (customentities[i].y*8)- (ed.levy*30*8); drawRect = graphics.tiles_rect; drawRect.x += tpoint.x; drawRect.y += tpoint.y; @@ -625,30 +625,30 @@ void editorrender(void) drawRect.x += 8; } - if(edentity[i].p1<=4) + if(customentities[i].p1<=4) { - if(edentity[i].p1==0) graphics.Print((edentity[i].x*8)- (ed.levx*40*8)+12,(edentity[i].y*8)- (ed.levy*30*8), "V", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); - if(edentity[i].p1==1) graphics.Print((edentity[i].x*8)- (ed.levx*40*8)+12,(edentity[i].y*8)- (ed.levy*30*8), "^", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); - if(edentity[i].p1==2) graphics.Print((edentity[i].x*8)- (ed.levx*40*8)+12,(edentity[i].y*8)- (ed.levy*30*8), "<", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); - if(edentity[i].p1==3) graphics.Print((edentity[i].x*8)- (ed.levx*40*8)+12,(edentity[i].y*8)- (ed.levy*30*8), ">", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),32,8,graphics.getBGR(255,255,255)); + if(customentities[i].p1==0) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+12,(customentities[i].y*8)- (ed.levy*30*8), "V", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); + if(customentities[i].p1==1) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+12,(customentities[i].y*8)- (ed.levy*30*8), "^", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); + if(customentities[i].p1==2) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+12,(customentities[i].y*8)- (ed.levy*30*8), "<", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); + if(customentities[i].p1==3) graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+12,(customentities[i].y*8)- (ed.levy*30*8), ">", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),32,8,graphics.getBGR(255,255,255)); } - if(edentity[i].p1==5) + if(customentities[i].p1==5) { - graphics.Print((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8), ">>>>", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),32,8,graphics.getBGR(255,255,255)); + graphics.Print((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8), ">>>>", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),32,8,graphics.getBGR(255,255,255)); } - else if(edentity[i].p1==6) + else if(customentities[i].p1==6) { - graphics.Print((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8), "<<<<", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),32,8,graphics.getBGR(255,255,255)); + graphics.Print((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8), "<<<<", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),32,8,graphics.getBGR(255,255,255)); } - if(edentity[i].p1>=7) + if(customentities[i].p1>=7) { - tpoint.x = (edentity[i].x*8)- (ed.levx*40*8)+32; - tpoint.y = (edentity[i].y*8)- (ed.levy*30*8); + tpoint.x = (customentities[i].x*8)- (ed.levx*40*8)+32; + tpoint.y = (customentities[i].y*8)- (ed.levy*30*8); drawRect = graphics.tiles_rect; drawRect.x += tpoint.x; drawRect.y += tpoint.y; @@ -659,15 +659,15 @@ void editorrender(void) } } - if(edentity[i].p1==7) + if(customentities[i].p1==7) { - graphics.Print((edentity[i].x*8)- (ed.levx*40*8)+4,(edentity[i].y*8)- (ed.levy*30*8), "> > > > ", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),64,8,graphics.getBGR(255,255,255)); + graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+4,(customentities[i].y*8)- (ed.levy*30*8), "> > > > ", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),64,8,graphics.getBGR(255,255,255)); } - else if(edentity[i].p1==8) + else if(customentities[i].p1==8) { - graphics.Print((edentity[i].x*8)- (ed.levx*40*8)+4,(edentity[i].y*8)- (ed.levy*30*8), "< < < < ", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),64,8,graphics.getBGR(255,255,255)); + graphics.Print((customentities[i].x*8)- (ed.levx*40*8)+4,(customentities[i].y*8)- (ed.levy*30*8), "< < < < ", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),64,8,graphics.getBGR(255,255,255)); } break; case 3: //Disappearing Platform @@ -675,8 +675,8 @@ void editorrender(void) { continue; } - tpoint.x = (edentity[i].x*8)- (ed.levx*40*8); - tpoint.y = (edentity[i].y*8)- (ed.levy*30*8); + tpoint.x = (customentities[i].x*8)- (ed.levx*40*8); + tpoint.y = (customentities[i].y*8)- (ed.levy*30*8); drawRect = graphics.tiles_rect; drawRect.x += tpoint.x; drawRect.y += tpoint.y; @@ -686,87 +686,87 @@ void editorrender(void) drawRect.x += 8; } - graphics.Print((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8), "////", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),32,8,graphics.getBGR(255,255,255)); + graphics.Print((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8), "////", 255 - help.glow, 255 - help.glow, 255 - help.glow, false); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),32,8,graphics.getBGR(255,255,255)); break; case 9: //Shiny Trinket - graphics.drawsprite((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),22,196,196,196); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(164,164,255)); + graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),22,196,196,196); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(164,164,255)); break; case 10: //Checkpoints - graphics.drawsprite((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),20 + edentity[i].p1,196,196,196); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(164,164,255)); + graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),20 + customentities[i].p1,196,196,196); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(164,164,255)); break; case 11: //Gravity lines - if(edentity[i].p1==0) //Horizontal + if(customentities[i].p1==0) //Horizontal { - int tx = edentity[i].p2; - int tx2 = tx + edentity[i].p3/8; - int ty = edentity[i].y % 30; + int tx = customentities[i].p2; + int tx2 = tx + customentities[i].p3/8; + int ty = customentities[i].y % 30; FillRect(graphics.backBuffer, (tx*8),(ty*8)+4, (tx2-tx)*8,1, graphics.getRGB(194,194,194)); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(164,255,164)); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(164,255,164)); } else //Vertical { - int tx = edentity[i].x % 40; - int ty = edentity[i].p2; - int ty2 = ty + edentity[i].p3/8; + int tx = customentities[i].x % 40; + int ty = customentities[i].p2; + int ty2 = ty + customentities[i].p3/8; FillRect(graphics.backBuffer, (tx*8)+3,(ty*8), 1,(ty2-ty)*8, graphics.getRGB(194,194,194)); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(164,255,164)); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(164,255,164)); } break; case 13://Warp tokens - graphics.drawsprite((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),18+(ed.entframe%2),196,196,196); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(164,164,255)); + graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),18+(ed.entframe%2),196,196,196); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,16,graphics.getRGB(164,164,255)); if(temp2==i) { - graphics.bprint((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8)-8, - "("+help.String(((edentity[i].p1-int(edentity[i].p1%40))/40)+1)+","+help.String(((edentity[i].p2-int(edentity[i].p2%30))/30)+1)+")",210,210,255); + graphics.bprint((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8, + "("+help.String(((customentities[i].p1-int(customentities[i].p1%40))/40)+1)+","+help.String(((customentities[i].p2-int(customentities[i].p2%30))/30)+1)+")",210,210,255); } else { - graphics.bprint((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8)-8,help.String(cl.findwarptoken(i)),210,210,255); + graphics.bprint((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,help.String(cl.findwarptoken(i)),210,210,255); } break; case 15: //Crewmates - graphics.drawsprite((edentity[i].x*8)- (ed.levx*40*8)-4,(edentity[i].y*8)- (ed.levy*30*8),144,graphics.crewcolourreal(edentity[i].p1)); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),16,24,graphics.getRGB(164,164,164)); + graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8)-4,(customentities[i].y*8)- (ed.levy*30*8),144,graphics.crewcolourreal(customentities[i].p1)); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,24,graphics.getRGB(164,164,164)); break; case 16: //Start - if(edentity[i].p1==0) //Left + if(customentities[i].p1==0) //Left { - graphics.drawsprite((edentity[i].x*8)- (ed.levx*40*8)-4,(edentity[i].y*8)- (ed.levy*30*8),0,graphics.col_crewcyan); + graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8)-4,(customentities[i].y*8)- (ed.levy*30*8),0,graphics.col_crewcyan); } - else if(edentity[i].p1==1) + else if(customentities[i].p1==1) { - graphics.drawsprite((edentity[i].x*8)- (ed.levx*40*8)-4,(edentity[i].y*8)- (ed.levy*30*8),3,graphics.col_crewcyan); + graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8)-4,(customentities[i].y*8)- (ed.levy*30*8),3,graphics.col_crewcyan); } - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),16,24,graphics.getRGB(164,255,255)); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,24,graphics.getRGB(164,255,255)); if(ed.entframe<2) { - graphics.bprint((edentity[i].x*8)- (ed.levx*40*8)-12,(edentity[i].y*8)- (ed.levy*30*8)-8,"START",255,255,255); + graphics.bprint((customentities[i].x*8)- (ed.levx*40*8)-12,(customentities[i].y*8)- (ed.levy*30*8)-8,"START",255,255,255); } else { - graphics.bprint((edentity[i].x*8)- (ed.levx*40*8)-12,(edentity[i].y*8)- (ed.levy*30*8)-8,"START",196,196,196); + graphics.bprint((customentities[i].x*8)- (ed.levx*40*8)-12,(customentities[i].y*8)- (ed.levy*30*8)-8,"START",196,196,196); } break; case 17: //Roomtext - if(edentity[i].scriptname.length()<1) + if(customentities[i].scriptname.length()<1) { - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(96,96,96)); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(96,96,96)); } else { - int length = utf8::unchecked::distance(edentity[i].scriptname.begin(), edentity[i].scriptname.end()); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),length*8,8,graphics.getRGB(96,96,96)); + int length = utf8::unchecked::distance(customentities[i].scriptname.begin(), customentities[i].scriptname.end()); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),length*8,8,graphics.getRGB(96,96,96)); } - graphics.Print((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8), edentity[i].scriptname, 196, 196, 255 - help.glow); + graphics.Print((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8), customentities[i].scriptname, 196, 196, 255 - help.glow); break; case 18: //Terminals { - int usethistile = edentity[i].p1; - int usethisy = (edentity[i].y % 30) * 8; + int usethistile = customentities[i].p1; + int usethisy = (customentities[i].y % 30) * 8; // Not a boolean: just swapping 0 and 1, leaving the rest alone if (usethistile == 0) { @@ -777,88 +777,88 @@ void editorrender(void) usethistile = 0; // Flipped; usethisy -= 8; } - graphics.drawsprite((edentity[i].x*8)- (ed.levx*40*8), usethisy + 8, usethistile + 16, 96,96,96); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),16,24,graphics.getRGB(164,164,164)); + graphics.drawsprite((customentities[i].x*8)- (ed.levx*40*8), usethisy + 8, usethistile + 16, 96,96,96); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),16,24,graphics.getRGB(164,164,164)); if(temp2==i) { - graphics.bprint((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8)-8,edentity[i].scriptname,210,210,255); + graphics.bprint((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,customentities[i].scriptname,210,210,255); } break; } case 19: //Script Triggers - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),edentity[i].p1*8,edentity[i].p2*8,graphics.getRGB(255,164,255)); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(255,255,255)); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),customentities[i].p1*8,customentities[i].p2*8,graphics.getRGB(255,164,255)); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(255,255,255)); if(temp2==i) { - graphics.bprint((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8)-8,edentity[i].scriptname,210,210,255); + graphics.bprint((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8)-8,customentities[i].scriptname,210,210,255); } break; case 50: //Warp lines - if(edentity[i].p1>=2) //Horizontal + if(customentities[i].p1>=2) //Horizontal { - int tx=edentity[i].x-(ed.levx*40); - int tx2=edentity[i].x-(ed.levx*40); - int ty=edentity[i].y-(ed.levy*30); - if (edentity[i].p4 != 1) + int tx=customentities[i].x-(ed.levx*40); + int tx2=customentities[i].x-(ed.levx*40); + int ty=customentities[i].y-(ed.levy*30); + if (customentities[i].p4 != 1) { // Unlocked while(ed.free(tx,ty)==0) tx--; while(ed.free(tx2,ty)==0) tx2++; tx++; - edentity[i].p2=tx; - edentity[i].p3=(tx2-tx)*8; + customentities[i].p2=tx; + customentities[i].p3=(tx2-tx)*8; } else { // Locked - tx = edentity[i].p2; - tx2 = tx + edentity[i].p3/8; + tx = customentities[i].p2; + tx2 = tx + customentities[i].p3/8; } fillboxabs((tx*8),(ty*8)+1, (tx2-tx)*8,6, graphics.getRGB(255,255,194)); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(255,255,164)); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(255,255,164)); } else //Vertical { - int tx=edentity[i].x-(ed.levx*40); - int ty=edentity[i].y-(ed.levy*30); - int ty2=edentity[i].y-(ed.levy*30); - if (edentity[i].p4 != 1) + int tx=customentities[i].x-(ed.levx*40); + int ty=customentities[i].y-(ed.levy*30); + int ty2=customentities[i].y-(ed.levy*30); + if (customentities[i].p4 != 1) { // Unlocked while(ed.free(tx,ty)==0) ty--; while(ed.free(tx,ty2)==0) ty2++; ty++; - edentity[i].p2=ty; - edentity[i].p3=(ty2-ty)*8; + customentities[i].p2=ty; + customentities[i].p3=(ty2-ty)*8; } else { // Locked - ty = edentity[i].p2; - ty2 = ty + edentity[i].p3/8; + ty = customentities[i].p2; + ty2 = ty + customentities[i].p3/8; } fillboxabs((tx*8)+1,(ty*8), 6,(ty2-ty)*8, graphics.getRGB(255,255,194)); - fillboxabs((edentity[i].x*8)- (ed.levx*40*8),(edentity[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(255,255,164)); + fillboxabs((customentities[i].x*8)- (ed.levx*40*8),(customentities[i].y*8)- (ed.levy*30*8),8,8,graphics.getRGB(255,255,164)); } break; } } //Need to also check warp point destinations - if(edentity[i].t==13 && ed.warpent!=i) + if(customentities[i].t==13 && ed.warpent!=i) { - if (edentity[i].p1 / 40 == ed.levx && edentity[i].p2 / 30 == ed.levy) + if (customentities[i].p1 / 40 == ed.levx && customentities[i].p2 / 30 == ed.levy) { - graphics.drawsprite((edentity[i].p1*8)- (ed.levx*40*8),(edentity[i].p2*8)- (ed.levy*30*8),18+(ed.entframe%2),64,64,64); - fillboxabs((edentity[i].p1*8)- (ed.levx*40*8),(edentity[i].p2*8)- (ed.levy*30*8),16,16,graphics.getRGB(64,64,96)); - if(ed.tilex+(ed.levx*40)==edentity[i].p1 && ed.tiley+(ed.levy*30)==edentity[i].p2) + graphics.drawsprite((customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8),18+(ed.entframe%2),64,64,64); + fillboxabs((customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8),16,16,graphics.getRGB(64,64,96)); + if(ed.tilex+(ed.levx*40)==customentities[i].p1 && ed.tiley+(ed.levy*30)==customentities[i].p2) { - graphics.bprint((edentity[i].p1*8)- (ed.levx*40*8),(edentity[i].p2*8)- (ed.levy*30*8)-8, - "("+help.String(((edentity[i].x-int(edentity[i].x%40))/40)+1)+","+help.String(((edentity[i].y-int(edentity[i].y%30))/30)+1)+")",190,190,225); + graphics.bprint((customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8)-8, + "("+help.String(((customentities[i].x-int(customentities[i].x%40))/40)+1)+","+help.String(((customentities[i].y-int(customentities[i].y%30))/30)+1)+")",190,190,225); } else { - graphics.bprint((edentity[i].p1*8)- (ed.levx*40*8),(edentity[i].p2*8)- (ed.levy*30*8)-8,help.String(cl.findwarptoken(i)),190,190,225); + graphics.bprint((customentities[i].p1*8)- (ed.levx*40*8),(customentities[i].p2*8)- (ed.levy*30*8)-8,help.String(cl.findwarptoken(i)),190,190,225); } } } @@ -1603,23 +1603,23 @@ void editorrenderfixed(void) } /* Correct gravity lines */ - for (size_t i = 0; i < edentity.size(); ++i) + for (size_t i = 0; i < customentities.size(); ++i) { - if (edentity[i].x / 40 != ed.levx - || edentity[i].y / 30 != ed.levy - || edentity[i].t != 11 + if (customentities[i].x / 40 != ed.levx + || customentities[i].y / 30 != ed.levy + || customentities[i].t != 11 /* Is the gravity line locked? */ - || edentity[i].p4 == 1) + || customentities[i].p4 == 1) { continue; } - if (edentity[i].p1 == 0) + if (customentities[i].p1 == 0) { /* Horizontal */ - int tx = edentity[i].x % 40; + int tx = customentities[i].x % 40; int tx2 = tx; - int ty = edentity[i].y % 30; + int ty = customentities[i].y % 30; while (!ed.spikefree(tx, ty)) { --tx; @@ -1629,14 +1629,14 @@ void editorrenderfixed(void) ++tx2; } ++tx; - edentity[i].p2 = tx; - edentity[i].p3 = (tx2 - tx) * 8; + customentities[i].p2 = tx; + customentities[i].p3 = (tx2 - tx) * 8; } else { /* Vertical */ - int tx = edentity[i].x % 40; - int ty = edentity[i].y % 30; + int tx = customentities[i].x % 40; + int ty = customentities[i].y % 30; int ty2 = ty; /* Unlocked */ while (!ed.spikefree(tx, ty)) @@ -1648,8 +1648,8 @@ void editorrenderfixed(void) ++ty2; } ++ty; - edentity[i].p2 = ty; - edentity[i].p3 = (ty2 - ty) * 8; + customentities[i].p2 = ty; + customentities[i].p3 = (ty2 - ty) * 8; } } @@ -2715,13 +2715,13 @@ void editorinput(void) int testeditor=-1; int startpoint=0; //First up; is there a start point on this screen? - for(size_t i=0; i=5) + if(customentities[tmp].p1>=5) { - edentity[tmp].p1=(edentity[tmp].p1+1)%9; - if(edentity[tmp].p1<5) edentity[tmp].p1=5; + customentities[tmp].p1=(customentities[tmp].p1+1)%9; + if(customentities[tmp].p1<5) customentities[tmp].p1=5; } else { - edentity[tmp].p1=(edentity[tmp].p1+1)%4; + customentities[tmp].p1=(customentities[tmp].p1+1)%4; } ed.lclickdelay=1; } - else if(edentity[tmp].t==10) + else if(customentities[tmp].t==10) { // If it's not textured as a checkpoint, leave it alone - if (edentity[tmp].p1 == 0 || edentity[tmp].p1 == 1) + if (customentities[tmp].p1 == 0 || customentities[tmp].p1 == 1) { - edentity[tmp].p1=(edentity[tmp].p1+1)%2; + customentities[tmp].p1=(customentities[tmp].p1+1)%2; } ed.lclickdelay=1; } - else if(edentity[tmp].t==11) + else if(customentities[tmp].t==11) { - edentity[tmp].p1=(edentity[tmp].p1+1)%2; + customentities[tmp].p1=(customentities[tmp].p1+1)%2; ed.lclickdelay=1; } - else if(edentity[tmp].t==15) + else if(customentities[tmp].t==15) { - edentity[tmp].p1=(edentity[tmp].p1+1)%6; + customentities[tmp].p1=(customentities[tmp].p1+1)%6; ed.lclickdelay=1; } - else if(edentity[tmp].t==16) + else if(customentities[tmp].t==16) { - edentity[tmp].p1=(edentity[tmp].p1+1)%2; + customentities[tmp].p1=(customentities[tmp].p1+1)%2; ed.lclickdelay=1; } - else if(edentity[tmp].t==17) + else if(customentities[tmp].t==17) { - ed.getlin(TEXT_ROOMTEXT, "Enter roomtext:", &(edentity[tmp].scriptname)); + ed.getlin(TEXT_ROOMTEXT, "Enter roomtext:", &(customentities[tmp].scriptname)); ed.textent=tmp; ed.lclickdelay=1; } - else if(edentity[tmp].t==18 || edentity[tmp].t==19) + else if(customentities[tmp].t==18 || customentities[tmp].t==19) { ed.lclickdelay=1; ed.textent=tmp; - ed.getlin(TEXT_SCRIPT, "Enter script name:", &(edentity[ed.textent].scriptname)); - if (edentity[tmp].t == 18 - && (edentity[tmp].p1 == 0 || edentity[tmp].p1 == 1)) + ed.getlin(TEXT_SCRIPT, "Enter script name:", &(customentities[ed.textent].scriptname)); + if (customentities[tmp].t == 18 + && (customentities[tmp].p1 == 0 || customentities[tmp].p1 == 1)) { // Flip the terminal, but if it's not textured as a terminal leave it alone - edentity[tmp].p1 = (edentity[tmp].p1 + 1) % 2; + customentities[tmp].p1 = (customentities[tmp].p1 + 1) % 2; } } } @@ -3449,9 +3449,9 @@ void editorinput(void) { ed.placetilelocal(ed.tilex, ed.tiley, 0); } - for(size_t i=0; i edentity; +std::vector customentities; customlevelclass cl; # ifndef NO_EDITOR editorclass ed;