Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Infinite loop with loading text from file  (Read 1885 times)

0 Members and 1 Guest are viewing this topic.

Wolff

  • Newbie
  • *
  • Posts: 22
    • View Profile
Infinite loop with loading text from file
« on: August 14, 2018, 01:01:34 am »
Hello,
I have written a function that basically takes in a number and then looks for it in a file, then loads the text beneath does some things and stops when it encounters the next number.
It works perfectly on it's own, but when I put it in my SFML project (you guessed it - it's a game) it never stops and freezes the entire program.
For it to start running first the user has to input some things so when the list of things to do is complete it switches a bool statement to true, and when it does my function that's been waiting inside an if statement can run.
I've tried everything to make it stop after one iteration, but once the program goes into the function it never leaves ignoring my code that literally says - stop it when you load a certain line. Using the debugger I confirmed that it indeed loads that line, but then it just goes back to the start.
Might it be the fault of the main loop of an SFML window?

Wolff

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Infinite loop with loading text from file
« Reply #1 on: August 14, 2018, 12:09:22 pm »
If anyone thinks some snippets of code would help I would gladly provide them, although the issue seems more general like the placement of my function(?).

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Infinite loop with loading text from file
« Reply #2 on: August 14, 2018, 07:43:33 pm »
It'd help because it sounds like you're doing something wrong and your problem is very vague. SFML doesn't even have a main loop, you have the main loop and call SFML functions, it's not an engine or something.
Back to C++ gamedev with SFML in May 2023

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: Infinite loop with loading text from file
« Reply #3 on: August 16, 2018, 06:48:39 pm »
yeah, i think we'll need the code  :P
Visit my game site (and hopefully help funding it? )
Website | IndieDB

 

anything