query game log even after application shuts down
This commit is contained in:
parent
58dfbe0e9d
commit
0782c4c2e9
|
|
@ -890,6 +890,26 @@ handle_event(const P3D_event_data &event) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DInstance::get_log_pathname
|
||||
// Access: Public
|
||||
// Description: Returns the log filename for this particular session,
|
||||
// if the session was started and if it has a log file.
|
||||
// Returns empty string if the session never started or
|
||||
// if it lacks a log file.
|
||||
//
|
||||
// This is the same value returned by
|
||||
// P3DSession::get_log_pathname(), except that it
|
||||
// remains valid even after the session has closed.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
const string &P3DInstance::
|
||||
get_log_pathname() const {
|
||||
if (_session != NULL) {
|
||||
return _session->_log_pathname;
|
||||
}
|
||||
return _log_pathname;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: P3DInstance::add_package
|
||||
// Access: Public
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ public:
|
|||
|
||||
inline int get_instance_id() const;
|
||||
inline const string &get_session_key() const;
|
||||
const string &get_log_pathname() const;
|
||||
|
||||
inline P3DSession *get_session() const;
|
||||
|
||||
|
|
@ -265,6 +266,7 @@ private:
|
|||
|
||||
P3DSession *_session;
|
||||
P3DAuthSession *_auth_session;
|
||||
string _log_pathname;
|
||||
|
||||
#ifdef __APPLE__
|
||||
// On OSX, we have to get a copy of the framebuffer data back from
|
||||
|
|
|
|||
|
|
@ -25,9 +25,10 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
P3DMainObject::
|
||||
P3DMainObject() :
|
||||
_pyobj(NULL)
|
||||
_pyobj(NULL),
|
||||
_inst(NULL),
|
||||
_unauth_play(false)
|
||||
{
|
||||
_unauth_play = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -297,6 +298,12 @@ get_pyobj() const {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
void P3DMainObject::
|
||||
set_instance(P3DInstance *inst) {
|
||||
if (_inst != NULL) {
|
||||
// Save the game log filename of the instance just before it goes
|
||||
// away, in case JavaScript asks for it later.
|
||||
_game_log_pathname = _inst->get_log_pathname();
|
||||
}
|
||||
|
||||
_inst = inst;
|
||||
}
|
||||
|
||||
|
|
@ -350,24 +357,22 @@ call_play(P3D_object *params[], int num_params) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
P3D_object *P3DMainObject::
|
||||
call_read_game_log(P3D_object *params[], int num_params) {
|
||||
if (_inst != NULL) {
|
||||
nout << "querying " << _inst << "->_log_pathname\n";
|
||||
string log_pathname = _inst->get_log_pathname();
|
||||
nout << "result is " << log_pathname << "\n";
|
||||
return read_log(log_pathname, params, num_params);
|
||||
}
|
||||
|
||||
if (!_game_log_pathname.empty()) {
|
||||
// The instance has already finished, but we saved its log
|
||||
// filename.
|
||||
return read_log(_game_log_pathname, params, num_params);
|
||||
}
|
||||
|
||||
// No log available for us.
|
||||
P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
|
||||
if (_inst == NULL) {
|
||||
return inst_mgr->new_undefined_object();
|
||||
}
|
||||
|
||||
if (!_inst->get_matches_script_origin()) {
|
||||
// If you're not allowed to be scripting us, you can't query the
|
||||
// game log either. (But you can query the system log.)
|
||||
return inst_mgr->new_undefined_object();
|
||||
}
|
||||
|
||||
P3DSession *session = _inst->get_session();
|
||||
if (session == NULL) {
|
||||
return inst_mgr->new_undefined_object();
|
||||
}
|
||||
|
||||
string log_pathname = session->get_log_pathname();
|
||||
return read_log(log_pathname, params, num_params);
|
||||
return inst_mgr->new_undefined_object();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ private:
|
|||
P3DInstance *_inst;
|
||||
|
||||
bool _unauth_play;
|
||||
string _game_log_pathname;
|
||||
|
||||
// This map is used to store properties and retrieve until
|
||||
// set_pyobj() is called for the firs ttime. At that point, the
|
||||
|
|
|
|||
|
|
@ -273,6 +273,8 @@ terminate_instance(P3DInstance *inst) {
|
|||
|
||||
ACQUIRE_LOCK(_instances_lock);
|
||||
if (inst->_session == this) {
|
||||
nout << "Assigning " << inst << "->log_pathname = " << _log_pathname << "\n";
|
||||
inst->_log_pathname = _log_pathname;
|
||||
inst->_session = NULL;
|
||||
_instances.erase(inst->get_instance_id());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue