about summary refs log tree commit diff stats
path: root/tools/assign_ids/main.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Added symbol shuffleStar Rauchenberger2025-09-091-0/+18
| | | | | Also fixed unlocked letters + any double letter cyan doors, and tweaked some logic related to important panels with symbols on them.
* Downgrade protobufStar Rauchenberger2025-09-081-0/+1
| | | | This allows the generated Python file to be compatible with the frozen Archipelago install.
* Added door groupsStar Rauchenberger2025-09-071-0/+20
|
* [Data] Strip unnecessary AP IDsStar Rauchenberger2025-09-041-16/+61
| | | | This was causing issues in the client, specifically for The Ancient.
* Added keyholder sanityStar Rauchenberger2025-09-021-0/+23
|
* Added progressive doorsStar Rauchenberger2025-09-011-33/+31
|
* Prevent assigning ap_id==0Star Rauchenberger2025-08-271-1/+1
|
* Added "endings" object typeStar Rauchenberger2025-08-201-0/+13
|
* Store IDs in a yaml fileStar Rauchenberger2025-08-191-9/+8
| | | | This is much more efficient than the txtpb format, and we only need an interface for it in C++ since the IDs will be packed into the binary proto representation.
* Minor changes for compiling on WindowsStar Rauchenberger2025-08-161-1/+1
|
* Converted to proto2Star Rauchenberger2025-08-121-2/+1
| | | | | | | | | | | | | | | | | This will let us use an older version of protobuf in Python, and allows us to use the Godot protobuf implementation at all. Scalar fields with custom defaults in data.proto were changed to not have a default, because Godot doesn't handle it properly. The equivalent fields in human.proto still have the defaults, and datapacker copies the default value in if necessary. The Panel message in data.proto was also renamed to PanelData because otherwise it conflicts with the native Godot class named Panel. The double field in Letter was renamed to level2, because Godot couldn't handle it well. Finally, common.proto was removed and its contents were moved into data.proto, which allows us to generate code for Python without needing to edit it. NOTE: I had to slightly modify the Godot protobuf code generator. I'll need to upload that somewhere.
* Assigned IDs for the_colorfulStar Rauchenberger2025-08-101-0/+12
| | | | | | Also fixed bug where the ID assigner didn't read letter and mastery IDs and would thus reuse them. I reassigned all IDs because of this (since we don't need to worry about ID stability yet).
* Added support for masteriesStar Rauchenberger2025-08-091-0/+30
| | | | | Also assigned IDs for the_butterfly, as well as already configured letters.
* Assigned IDs for the_bearerStar Rauchenberger2025-08-091-0/+4
| | | | | assign_ids now doesn't assign IDs for event doors, since they can't ever be locations or items.
* Added special IDsStar Rauchenberger2025-08-071-0/+8
|
* Assign AP IDs to doors and panelsStar Rauchenberger2025-08-071-0/+172
database.cpp?id=a7645346293ed6a912c26d0c50b6f7943f1f3072'>a764534 ^
6746da6 ^
e1fa4a0 ^
a764534 ^
6746da6 ^
a764534 ^
6746da6 ^
e1fa4a0 ^
a764534 ^
6746da6 ^
a764534 ^


e4fa0cb ^































a764534 ^





























6746da6 ^

350bfdb ^










6746da6 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180


                     
                  
                  
                    














                                                                                       




























                                                                                                         






















                                                   
 
                                                                                 
   
                                                                                      
   
 
                                                                             
   
                                                                                    
   
 
                                                                               
   
                                                                                     
   
 
                                                                             
   
                                                                                    
   
 
                                                                             
   
                                                                                    
   
 
                                                                                               
   


                                                                                             































                                                                                                         





























                                                                                                         

   










                                                                              
  
#include "database.h"
#include <sqlite3.h>
#include <stdexcept>
#include <sstream>
#include "query.h"
#include "version.h"

namespace verbly {

  database::database(std::string path)
  {
    if (sqlite3_open_v2(path.c_str(), &ppdb_, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK)
    {
      // We still have to free the resources allocated. In the event that
      // allocation failed, ppdb will be null and sqlite3_close_v2 will just
      // ignore it.
      std::string errmsg(sqlite3_errmsg(ppdb_));
      sqlite3_close_v2(ppdb_);

      throw database_error("Could not open verbly datafile", errmsg);
    }

    std::string queryString = "SELECT major, minor FROM version";

    sqlite3_stmt* ppstmt;
    if (sqlite3_prepare_v2(ppdb_, queryString.c_str(), queryString.length(), &ppstmt, NULL) != SQLITE_OK)
    {
      std::string errorMsg = sqlite3_errmsg(ppdb_);
      sqlite3_finalize(ppstmt);

      throw database_error("Error reading database version", errorMsg);
    }

    if (sqlite3_step(ppstmt) != SQLITE_ROW)
    {
      std::string errorMsg = sqlite3_errmsg(ppdb_);
      sqlite3_finalize(ppstmt);

      throw database_error("Error reading database version", errorMsg);
    }

    major_ = sqlite3_column_int(ppstmt, 0);
    minor_ = sqlite3_column_int(ppstmt, 1);

    sqlite3_finalize(ppstmt);

    if (major_ != DATABASE_MAJOR_VERSION)
    {
      throw database_version_mismatch(DATABASE_MAJOR_VERSION, major_);
    }
  }

  database::database(database&& other) : database()
  {
    swap(*this, other);
  }

  database& database::operator=(database&& other)
  {
    swap(*this, other);

    return *this;
  }

  void swap(database& first, database& second)
  {
    std::swap(first.ppdb_, second.ppdb_);
  }

  database::~database()
  {
    sqlite3_close_v2(ppdb_);
  }

  query<notion> database::notions(filter where, order sortOrder, int limit) const
  {
    return query<notion>(*this, ppdb_, std::move(where), std::move(sortOrder), limit);
  }

  query<word> database::words(filter where, order sortOrder, int limit) const
  {
    return query<word>(*this, ppdb_, std::move(where), std::move(sortOrder), limit);
  }

  query<frame> database::frames(filter where, order sortOrder, int limit) const
  {
    return query<frame>(*this, ppdb_, std::move(where), std::move(sortOrder), limit);
  }

  query<part> database::parts(filter where, order sortOrder, int limit) const
  {
    return query<part>(*this, ppdb_, std::move(where), std::move(sortOrder), limit);
  }

  query<form> database::forms(filter where, order sortOrder, int limit) const
  {
    return query<form>(*this, ppdb_, std::move(where), std::move(sortOrder), limit);
  }

  query<pronunciation> database::pronunciations(filter where, order sortOrder, int limit) const
  {
    return query<pronunciation>(*this, ppdb_, std::move(where), std::move(sortOrder), limit);
  }

  std::set<std::string> database::selrestrs(int partId) const
  {
    std::string queryString = "SELECT selrestr FROM selrestrs WHERE part_id = ?";

    sqlite3_stmt* ppstmt;
    if (sqlite3_prepare_v2(ppdb_, queryString.c_str(), queryString.length(), &ppstmt, NULL) != SQLITE_OK)
    {
      std::string errorMsg = sqlite3_errmsg(ppdb_);
      sqlite3_finalize(ppstmt);

      throw database_error("Error preparing query", errorMsg);
    }

    if (sqlite3_bind_int(ppstmt, 1, partId) != SQLITE_OK)
    {
      std::string errorMsg = sqlite3_errmsg(ppdb_);
      sqlite3_finalize(ppstmt);

      throw database_error("Error binding value to query", errorMsg);
    }

    std::set<std::string> result;
    while (sqlite3_step(ppstmt) == SQLITE_ROW)
    {
      result.insert(reinterpret_cast<const char*>(sqlite3_column_blob(ppstmt, 0)));
    }

    sqlite3_finalize(ppstmt);

    return result;
  }

  std::set<std::string> database::synrestrs(int partId) const
  {
    std::string queryString = "SELECT synrestr FROM synrestrs WHERE part_id = ?";

    sqlite3_stmt* ppstmt;
    if (sqlite3_prepare_v2(ppdb_, queryString.c_str(), queryString.length(), &ppstmt, NULL) != SQLITE_OK)
    {
      std::string errorMsg = sqlite3_errmsg(ppdb_);
      sqlite3_finalize(ppstmt);

      throw database_error("Error preparing query", errorMsg);
    }

    if (sqlite3_bind_int(ppstmt, 1, partId) != SQLITE_OK)
    {
      std::string errorMsg = sqlite3_errmsg(ppdb_);
      sqlite3_finalize(ppstmt);

      throw database_error("Error binding value to query", errorMsg);
    }

    std::set<std::string> result;
    while (sqlite3_step(ppstmt) == SQLITE_ROW)
    {
      result.insert(reinterpret_cast<const char*>(sqlite3_column_blob(ppstmt, 0)));
    }

    sqlite3_finalize(ppstmt);

    return result;
  }

  std::string database_version_mismatch::generateMessage(int right, int wrong)
  {
    std::ostringstream msgbuilder;
    msgbuilder << "Incompatible database version: needed ";
    msgbuilder << right;
    msgbuilder << ", found ";
    msgbuilder << wrong;

    return msgbuilder.str();
  }

};