@@ -88,80 +88,59 @@ static bool EasyAdd(dyn_arg_list args) {
8888
8989 return true ;
9090}
91-
9291bool DynRpg::EasyRpgPlugin::EasyRaw (dyn_arg_list args, Game_Interpreter* interpreter) {
93- if (!interpreter) {
94- return true ;
95- }
96-
97- auto func = " easyrpg_raw" ;
98- bool okay = false ;
99-
100- lcf::rpg::EventCommand cmd;
101- std::vector<int32_t > output_args;
92+ if (!interpreter) return true ;
10293
10394 if (args.empty ()) {
10495 Output::Warning (" easyrpg_raw: Command too short" );
10596 return true ;
10697 }
10798
108- Constants Constants;
109- std::string keyToPrint = " ENABLE" ;
110-
111- // Output::Warning("Key {}, value {}", keyToPrint, Constants.get("DestinyScript",keyToPrint));
112-
113- auto evt = args[0 ];
114- if (evt.find (" @" ) == 0 ) {
115- evt = evt.substr (1 );
116- evt = Constants.get (" EventCode" , evt);
99+ Constants constList;
117100
118- cmd.code = stoi (evt);
119- okay = bool (cmd.code );
120- } else
121- std::tie (cmd.code ) = DynRpg::ParseArgs<int >(func, args, &okay);
122-
123- if (!okay) {
124- Output::Warning (" EasyRpgPlugin - Unknown Input: {}" ,args[0 ]);
125- return true ;
126- }
101+ const std::string func = " easyrpg_raw" ;
102+ bool okay = false ;
103+ int codeArgIndex = 0 ;
104+ int stringArgIndex = 1 ;
105+ bool endOfLine = false ;
127106
128- if (args. size () >= 2 ) {
129- auto [string_arg] = DynRpg::ParseArgs< std::string>(func, args. subspan ( 1 ), &okay) ;
130- cmd. string = lcf::DBString (string_arg) ;
107+ lcf::rpg::EventCommand cmd;
108+ std::vector< int32_t > outputArgs ;
109+ std::vector< lcf::rpg::EventCommand> cmdList ;
131110
132- if (!okay) {
133- return true ;
111+ for (size_t i = 0 ; i < args.size (); ++i) {
112+ if (i == args.size () - 1 ) {
113+ if (args[i].back () == ' ;' ) args[i] = args[i].substr (0 , args[i].length () - 1 );
114+ endOfLine = true ;
134115 }
135116
136- for (size_t i = 2 ; i < args.size (); ++i) {
137-
138-
139- auto currArg = args[i];
140-
141- if (currArg.find (" @" ) == 0 ) {
142- currArg = currArg.substr (1 );
143- currArg = Constants.get (" DestinyScript" , currArg);
144-
145- auto int_arg = stoi (currArg);
146- okay = true ;
147- output_args.push_back (int_arg);
148- }
149- else {
150- auto [int_arg] = DynRpg::ParseArgs<int >(func, args.subspan (i), &okay);
151- output_args.push_back (int_arg);
152- }
117+ // TODO: Implement multi-line command interpretation split by ';'.
153118
154-
155- if (!okay) {
156- return true ;
157- }
119+ if (i == codeArgIndex) {
120+ if (args[i].front () == ' @' ) args[i] = constList.get (" EventCode" , args[i].substr (1 ));
121+ std::tie (cmd.code ) = DynRpg::ParseArgs<int >(func, args, &okay);
122+ }
123+ else if (i == stringArgIndex) {
124+ auto [stringArg] = DynRpg::ParseArgs<std::string>(func, args.subspan (i), &okay);
125+ cmd.string = lcf::DBString (stringArg);
126+ }
127+ else {
128+ if (args[i].front () == ' @' ) args[i] = constList.get (" DestinyScript" , args[i].substr (1 ));
129+ auto [intArg] = DynRpg::ParseArgs<int >(func, args.subspan (i), &okay);
130+ outputArgs.push_back (intArg);
158131 }
159- }
160132
161- cmd.parameters = lcf::DBArray<int32_t >(output_args.begin (), output_args.end ());
133+ if (endOfLine) {
134+ codeArgIndex = i + 1 ;
135+ stringArgIndex = i + 2 ;
136+ cmd.parameters = lcf::DBArray<int32_t >(outputArgs.begin (), outputArgs.end ());
137+ cmdList.push_back (cmd);
138+ }
162139
163- interpreter->Push ({ cmd }, 0 , false );
140+ if (!okay) return true ;
141+ }
164142
143+ interpreter->Push (cmdList, 0 , false );
165144 return true ;
166145}
167146
0 commit comments