3333#include " core/io/compression.h"
3434#include " core/io/marshalls.h"
3535
36- #define TOKENIZER_VERSION 100
37-
3836int GDScriptTokenizerBuffer::_token_to_binary (const Token &p_token, Vector<uint8_t > &r_buffer, int p_start, HashMap<StringName, uint32_t > &r_identifiers_map, HashMap<Variant, uint32_t , VariantHasher, VariantComparator> &r_constants_map) {
3937 int pos = p_start;
4038
@@ -143,7 +141,7 @@ Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer)
143141 ERR_FAIL_COND_V (p_buffer.size () < 12 || p_buffer[0 ] != ' G' || p_buffer[1 ] != ' D' || p_buffer[2 ] != ' S' || p_buffer[3 ] != ' C' , ERR_INVALID_DATA);
144142
145143 int version = decode_uint32 (&buf[4 ]);
146- ERR_FAIL_COND_V_MSG (version > TOKENIZER_VERSION, ERR_INVALID_DATA, " Binary GDScript is too recent! Please use a newer engine version." );
144+ ERR_FAIL_COND_V_MSG (version != TOKENIZER_VERSION, ERR_INVALID_DATA, " Binary GDScript is not compatible with this engine version." );
147145
148146 int decompressed_size = decode_uint32 (&buf[8 ]);
149147
@@ -161,10 +159,10 @@ Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer)
161159 uint32_t identifier_count = decode_uint32 (&buf[0 ]);
162160 uint32_t constant_count = decode_uint32 (&buf[4 ]);
163161 uint32_t token_line_count = decode_uint32 (&buf[8 ]);
164- uint32_t token_count = decode_uint32 (&buf[16 ]);
162+ uint32_t token_count = decode_uint32 (&buf[12 ]);
165163
166- const uint8_t *b = &buf[20 ];
167- total_len -= 20 ;
164+ const uint8_t *b = &buf[16 ];
165+ total_len -= 16 ;
168166
169167 identifiers.resize (identifier_count);
170168 for (uint32_t i = 0 ; i < identifier_count; i++) {
@@ -292,14 +290,13 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code,
292290 }
293291
294292 Vector<uint8_t > contents;
295- contents.resize (20 );
293+ contents.resize (16 );
296294 encode_uint32 (identifier_map.size (), &contents.write [0 ]);
297295 encode_uint32 (constant_map.size (), &contents.write [4 ]);
298296 encode_uint32 (token_lines.size (), &contents.write [8 ]);
299- encode_uint32 (0 , &contents.write [12 ]); // Unused, kept for compatibility. Please remove at next `TOKENIZER_VERSION` increment.
300- encode_uint32 (token_counter, &contents.write [16 ]);
297+ encode_uint32 (token_counter, &contents.write [12 ]);
301298
302- int buf_pos = 20 ;
299+ int buf_pos = 16 ;
303300
304301 // Save identifiers.
305302 for (const StringName &id : rev_identifier_map) {
0 commit comments