| 40 | Player* Player::instance; |
| 41 | |
| 42 | void Player::readCommand() { |
| 43 | this->nextCommand.clear(); |
| 44 | this->nextValue.clear(); |
| 45 | |
| 46 | BString line; |
| 47 | if (!file.readLine(line)) { |
| 48 | klog("script finished: success"); |
| 49 | this->nextCommand = B("DONE"); // will cause success exit code to be returned |
| 50 | KSystem::killTime = KSystem::getMilliesSinceStart() + 30000; |
| 51 | return; |
| 52 | } |
| 53 | std::vector<BString> results; |
| 54 | line.split("=", results); |
| 55 | if (results.size() == 2) { |
| 56 | this->nextCommand = results[0]; |
| 57 | this->nextValue = results[1]; |
| 58 | } else if (results.size() == 1) { |
| 59 | this->nextCommand = results[0]; |
| 60 | } else { |
| 61 | klog_fmt("malformed script. Line = %s", line.c_str()); |
| 62 | #ifdef BOXEDWINE_MULTI_THREADED |
| 63 | KSystem::destroy(); |
| 64 | #endif |
| 65 | exit(99); |
| 66 | } |
| 67 | this->lastCommandTime = KSystem::getMicroCounter(); |
| 68 | if (this->nextCommand.length()==0) { |
| 69 | klog_fmt("malformed script. Line = %s", line.c_str()); |
| 70 | #ifdef BOXEDWINE_MULTI_THREADED |
| 71 | KSystem::destroy(); |
| 72 | #endif |
| 73 | exit(99); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | bool Player::start(BString directory) { |
| 78 | Player::instance = new Player(); |