objwriter.cxx

changeset 69
29a3e669d648
parent 68
588cc27e84bb
equal deleted inserted replaced
68:588cc27e84bb 69:29a3e669d648
61 numWrittenReferences = 0; 61 numWrittenReferences = 0;
62 filepath = path; 62 filepath = path;
63 } 63 }
64 64
65 void ObjWriter::WriteString (char* s) { 65 void ObjWriter::WriteString (char* s) {
66 Write<long> (strlen (s)); 66 Write (strlen (s));
67 for (unsigned int u = 0; u < strlen (s); u++) 67 for (unsigned int u = 0; u < strlen (s); u++)
68 Write<char> (s[u]); 68 Write ((s)[u]);
69 } 69 }
70 70
71 void ObjWriter::WriteString (const char* s) { 71 void ObjWriter::WriteString (const char* s) {
72 WriteString (const_cast<char*> (s)); 72 WriteString (const_cast<char*> (s));
73 } 73 }
81 } 81 }
82 82
83 void ObjWriter::WriteBuffers () { 83 void ObjWriter::WriteBuffers () {
84 // If there was no mainloop defined, write a dummy one now. 84 // If there was no mainloop defined, write a dummy one now.
85 if (!g_GotMainLoop) { 85 if (!g_GotMainLoop) {
86 MainLoopBuffer->Write<long> (DH_MAINLOOP); 86 MainLoopBuffer->Write (DH_MAINLOOP);
87 MainLoopBuffer->Write<long> (DH_ENDMAINLOOP); 87 MainLoopBuffer->Write (DH_ENDMAINLOOP);
88 } 88 }
89 89
90 // Write the onenter and mainloop buffers, IN THAT ORDER 90 // Write the onenter and mainloop buffers, IN THAT ORDER
91 for (int i = 0; i < 2; i++) { 91 for (int i = 0; i < 2; i++) {
92 DataBuffer* buf = (!i) ? OnEnterBuffer : MainLoopBuffer; 92 DataBuffer** buf = (!i) ? &OnEnterBuffer : &MainLoopBuffer;
93 WriteBuffer (buf); 93 WriteBuffer (*buf);
94 94
95 // Clear the buffer afterwards for potential next state 95 // Clear the buffer afterwards for potential next state
96 buf = new DataBuffer; 96 *buf = new DataBuffer;
97 } 97 }
98 98
99 // Next state definitely has no mainloop yet 99 // Next state definitely has no mainloop yet
100 g_GotMainLoop = false; 100 g_GotMainLoop = false;
101 } 101 }
105 unsigned int stringcount = CountStringTable (); 105 unsigned int stringcount = CountStringTable ();
106 if (!stringcount) 106 if (!stringcount)
107 return; 107 return;
108 108
109 // Write header 109 // Write header
110 Write<long> (DH_STRINGLIST); 110 Write (DH_STRINGLIST);
111 Write<long> (stringcount); 111 Write (stringcount);
112 112
113 // Write all strings 113 // Write all strings
114 for (unsigned int a = 0; a < stringcount; a++) 114 for (unsigned int a = 0; a < stringcount; a++)
115 WriteString (g_StringTable[a]); 115 WriteString (g_StringTable[a]);
116 } 116 }

mercurial