MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / WriteConditionalCodeBlock

Method WriteConditionalCodeBlock

editor/DallasMainDlg.cpp:10499–10540  ·  view source on GitHub ↗

Writes out the code body for a conditional header block (an IF statement)

Source from the content-addressed store, hash-verified

10497
10498// Writes out the code body for a conditional header block (an IF statement)
10499void CDallasMainDlg::WriteConditionalCodeBlock(HTREEITEM conditional_header_node) {
10500 tTreeNodeData *data, *action_hdr_data;
10501 HTREEITEM child_node, action_hdr_node;
10502
10503 if (CurrentOutputFile == NULL || conditional_header_node == NULL)
10504 return;
10505
10506 data = (tTreeNodeData *)m_ScriptTree.GetItemData(conditional_header_node);
10507 if (data == NULL || data->type != CONDITIONAL_HEADER_NODE)
10508 return;
10509
10510 // Get the first child (literal or query)
10511 child_node = m_ScriptTree.GetChildItem(conditional_header_node);
10512 if (child_node == NULL)
10513 return;
10514
10515 TabOver();
10516 cfprintf(CurrentOutputFile, "if(");
10517
10518 // Write out the max script execution times conditional (if it's not infinite)
10519 action_hdr_data = NULL;
10520 if (data->ID == TOP_LEVEL) {
10521 action_hdr_node = GetActionHeaderNode(conditional_header_node);
10522 if (action_hdr_node != NULL) {
10523 action_hdr_data = (tTreeNodeData *)m_ScriptTree.GetItemData(action_hdr_node);
10524 if (action_hdr_data != NULL && action_hdr_data->subID != 0) {
10525 CString tmp_name = CreateScriptGlobalCtrName(GetScriptID(action_hdr_node));
10526 cfprintf(CurrentOutputFile, "(%s < %d) && (", tmp_name.GetBuffer(0), action_hdr_data->subID);
10527 }
10528 }
10529 }
10530
10531 // Write out the conditional expressions
10532 WriteLogicalOpExpression(child_node);
10533
10534 // If max script execution expression was added, then tack on another parentheses
10535 if (action_hdr_data != NULL && action_hdr_data->subID != 0) {
10536 cfprintf(CurrentOutputFile, ")");
10537 }
10538
10539 O((")"));
10540}
10541
10542// Writes out a logical operation block (AND, OR)
10543void CDallasMainDlg::WriteLogicalOpExpression(HTREEITEM logop_node) {

Callers

nothing calls this directly

Calls 2

cfprintfFunction · 0.85
GetBufferMethod · 0.80

Tested by

no test coverage detected