What kind of story does the source code tell

Marc 2022-03-14 14:12:21

After thinking about it, the plot of the source code can be roughly represented by the following code

#include

#include

#include

#include

#include

#include

using namespace std;

struct World;

struct Person

{

std::vector m_Memories;

std::string m_Name;

World *m_pWorld = nullptr;

Person(const std::string &name)

: m_Name(name)

{}

};

int g_TrainThreadInited = 0;

int g_TrainThreadCrashed = 0;

int g_TryTimes = 0;

Person g_p1("Stevens"), g_p2("Sean");

struct World

{

Person *m_pMainCharacter = nullptr;

World(Person *character)

: m_pMainCharacter(character)

{}

void SadStory()

{

cout << "Boom !" << endl;

}

void HappyStory()

{

cout << "Mua !" << endl;

}

};

void TrainThread(World *pWorld)

{

try

{

if (g_TryTimes <8)

{

pWorld->SadStory();

++g_TryTimes;

throw std::exception("Boom !");

}

else

pWorld->HappyStory();

}

catch (std::exception &e)

{

pWorld->m_pMainCharacter->m_Memories.push_back(e.what());

g_TrainThreadCrashed = 1;

}

}

int main()

{

std::shared_ptr threadptr;

for (;;)

{

if (!g_TrainThreadInited || g_TrainThreadCrashed)

{

World w(&g_p2);

g_p1.m_pWorld = &w;

w.m_pMainCharacter = &g_p1;

threadptr.reset(new thread (TrainThread, &w));

threadptr->detach();

if (!g_TrainThreadInited)

g_TrainThreadInited = 1;

if (g_TrainThreadCrashed)

g_TrainThreadCrashed = 0;

}

}

return 0;

}

View more about Source Code reviews

Extended Reading
  • Gracie 2021-10-20 18:59:55

    The parallel world theory must be true, I firmly believe it

  • Vito 2022-03-23 09:01:13

    So lovely! From the very beginning, the plot was tight and uncomfortable, but the most awesome thing is that you thought it turned out to be like this, but it turned out not to be like this at all~! ! The director of the moon is awesome~~ T_T dared to give five stars, because I was very touched, the last clip reminded me of the last scene in "Avatar" where I suddenly opened my eyes. Those who like Canon's "LEAVE ME" should not miss it~

Source Code quotes

  • Derek Frost: The world is Hell. We have a chance to start over in the rubble. But first, there has to be rubble.

  • Colleen Goodwin: Memory thread one. Listen to the following passage. "Lilly awoke in an evening dress and opera cloak. In her hand were five playing cards."

    Colter Stevens: Is this a joke?

    Colleen Goodwin: "They were, the queen of spades, four of clubs, nine of clubs, three of hearts, nine of hearts. "

    Colter Stevens: Is this a Red Flag exercise?

    Colleen Goodwin: End of thread one. Thread two. The following is a recording of a Western Screech Owl.

    [audio of owl]

    Colleen Goodwin: End of thread two. End of pattern. Acknowledge.

    Colter Stevens: Acknowledge end of pattern.

    Colleen Goodwin: Stand by to initiate pattern recall.

    Colter Stevens: Go for pattern recall.

    Colleen Goodwin: Arrange the five playing cards in order of descending value, irrespective of suit.

    Colter Stevens: Queen, two nines, four and a three.

    Colleen Goodwin: That is correct.The passage I read contained mention of a woman's name. What was that name?

    Colter Stevens: Her name was Lilly.

    Colleen Goodwin: That is correct. Recall my name.

    Colter Stevens: Goodwin. Your name's Goodwin.

    Colleen Goodwin: That is correct. Welcome back, Captain.