@@ -88,80 +88,59 @@ static bool EasyAdd(dyn_arg_list args) {
88
88
89
89
return true ;
90
90
}
91
-
92
91
bool 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 ;
102
93
103
94
if (args.empty ()) {
104
95
Output::Warning (" easyrpg_raw: Command too short" );
105
96
return true ;
106
97
}
107
98
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;
117
100
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 ;
127
106
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 ;
131
110
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 ;
134
115
}
135
116
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 ';'.
153
118
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);
158
131
}
159
- }
160
132
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
+ }
162
139
163
- interpreter->Push ({ cmd }, 0 , false );
140
+ if (!okay) return true ;
141
+ }
164
142
143
+ interpreter->Push (cmdList, 0 , false );
165
144
return true ;
166
145
}
167
146
0 commit comments