Browse Source

Fix bug that caused bossrush not to start

Because of a bad ordering in function calls, walls_vec was used before
being initialized, causing the program bossrush not to start.
Matteo Zeccoli Marazzini 4 years ago
parent
commit
48bb50db17
1 changed files with 13 additions and 13 deletions
  1. 13 13
      bossrush.cpp

+ 13 - 13
bossrush.cpp

@@ -112,7 +112,7 @@ int main(int argc,char** argv)
 	boss1.alive=true;
 
 	player1.weaponclass=1;
-	
+
 	//NCURSES STUFF
 	initscr();
 	curs_set(0);
@@ -130,33 +130,33 @@ int main(int argc,char** argv)
 	init_pair(7,COLOR_RED,COLOR_RED);
 	init_pair(8,COLOR_GREEN,COLOR_GREEN);
 	init_pair(9,COLOR_BLACK,COLOR_GREEN);
-	
-	w_vec walls(walls_num);
-	
+
 	Score=newwin(3,10,R/3,C+3);
 	BossHP=newwin(3,15,R/3-3,C+3);
-	
+
+	level = choose_level_bossrush(commands);
+	setup_level_bossrush(level, shootrate, poweruprate, walls_num, refresh_time);
+
+	w_vec walls(walls_num);
 	int i=0;
 	for(w_vec::iterator it=walls.begin(); it!=walls.end(); ++it, ++i)				//creating walls (in a quite symmetric pattern)
 		it->create((i+1)*(C/(3*walls_num+1))+i*(2*C/(3*walls_num+1)),2*R/3,(int)min(6,2*C/(3*walls_num+1)),2,3);
 
-	level = choose_level_bossrush(commands);
-	setup_level_bossrush(level, shootrate, poweruprate, walls_num, refresh_time);
-	
+
 	player1.set_commands(commands);
-	
+
 	if(level<3)
 		player1.weaponclass=2;
 
 	erase();
-	
+
 	if(argc>1)
 		if(strcmp(argv[1],"--uber-debug")==0){ player1.weaponclass=5; player1.weaponclassrkt=5; player1.rocketlauncher=true; player1.length=MAX_LENGTH; }
-	
+
 	std::thread t_draw(draw,std::ref(player1),std::ref(bullets),std::ref(bombs),std::ref(enemies),std::ref(walls),std::ref(powerups),std::ref(rockets),std::ref(boss1));
-	
+
 /////////ENTERING MAIN LOOP
-	
+
 	while(1)
 	{
 		napms(refresh_time);					//ncurses sleep function (ms)