1.1 --- a/plugins/include/protobuf.inc Sat Mar 16 13:30:00 2013 -0400
1.2 +++ b/plugins/include/protobuf.inc Sat Mar 16 13:31:35 2013 -0400
1.3 @@ -35,35 +35,40 @@
1.4 #endif
1.5 #define _protobuf_included
1.6
1.7 +#define PB_FIELD_NOT_REPEATED -1
1.8 +
1.9 /**
1.10 * Reads an int32, uint32, sint32, fixed32, or sfixed32 from a protobuf message.
1.11 *
1.12 * @param pb protobuf handle.
1.13 * @param field Field name.
1.14 + * @param index Index into repeated field.
1.15 * @return Integer value read.
1.16 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.17 */
1.18 -native PbReadInt(Handle:pb, const String:field[]);
1.19 +native PbReadInt(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEATED);
1.20
1.21 /**
1.22 * Reads a float or downcasted double from a protobuf message.
1.23 *
1.24 * @param pb protobuf handle.
1.25 * @param field Field name.
1.26 + * @param index Index into repeated field.
1.27 * @return Float value read.
1.28 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.29 */
1.30 -native Float:PbReadFloat(Handle:pb, const String:field[]);
1.31 +native Float:PbReadFloat(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEATED);
1.32
1.33 /**
1.34 * Reads a bool from a protobuf message.
1.35 *
1.36 * @param pb protobuf handle.
1.37 * @param field Field name.
1.38 + * @param index Index into repeated field.
1.39 * @return Boolean value read.
1.40 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.41 */
1.42 -native bool:PbReadBool(Handle:pb, const String:field[]);
1.43 +native bool:PbReadBool(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEATED);
1.44
1.45 /**
1.46 * Reads a string from a protobuf message.
1.47 @@ -72,10 +77,11 @@
1.48 * @param field Field name.
1.49 * @param buffer Destination string buffer.
1.50 * @param maxlength Maximum length of output string buffer.
1.51 + * @param index Index into repeated field.
1.52 * @noreturn
1.53 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.54 */
1.55 -native PbReadString(Handle:pb, const String:field[], String:buffer[], maxlength);
1.56 +native PbReadString(Handle:pb, const String:field[], String:buffer[], maxlength, index=PB_FIELD_NOT_REPEATED);
1.57
1.58 /**
1.59 * Reads an RGBA color value from a protobuf message.
1.60 @@ -83,10 +89,11 @@
1.61 * @param pb protobuf handle.
1.62 * @param field Field name.
1.63 * @param buffer Destination color buffer.
1.64 + * @param index Index into repeated field.
1.65 * @noreturn
1.66 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.67 */
1.68 -native PbReadColor(Handle:pb, const String:field[], buffer[4]);
1.69 +native PbReadColor(Handle:pb, const String:field[], buffer[4], index=PB_FIELD_NOT_REPEATED);
1.70
1.71 /**
1.72 * Reads an XYZ angle value from a protobuf message.
1.73 @@ -94,10 +101,11 @@
1.74 * @param pb protobuf handle.
1.75 * @param field Field name.
1.76 * @param buffer Destination angle buffer.
1.77 + * @param index Index into repeated field.
1.78 * @noreturn
1.79 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.80 */
1.81 -native PbReadAngle(Handle:pb, const String:field[], Float:buffer[3]);
1.82 +native PbReadAngle(Handle:pb, const String:field[], Float:buffer[3], index=PB_FIELD_NOT_REPEATED);
1.83
1.84 /**
1.85 * Reads an XYZ vector value from a protobuf message.
1.86 @@ -105,10 +113,11 @@
1.87 * @param pb protobuf handle.
1.88 * @param field Field name.
1.89 * @param buffer Destination vector buffer.
1.90 + * @param index Index into repeated field.
1.91 * @noreturn
1.92 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.93 */
1.94 -native PbReadVector(Handle:pb, const String:field[], Float:buffer[3]);
1.95 +native PbReadVector(Handle:pb, const String:field[], Float:buffer[3], index=PB_FIELD_NOT_REPEATED);
1.96
1.97 /**
1.98 * Reads an XY vector value from a protobuf message.
1.99 @@ -116,10 +125,11 @@
1.100 * @param pb protobuf handle.
1.101 * @param field Field name.
1.102 * @param buffer Destination vector buffer.
1.103 + * @param index Index into repeated field.
1.104 * @noreturn
1.105 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.106 */
1.107 -native PbReadVector2D(Handle:pb, const String:field[], Float:buffer[2]);
1.108 +native PbReadVector2D(Handle:pb, const String:field[], Float:buffer[2], index=PB_FIELD_NOT_REPEATED);
1.109
1.110 /**
1.111 * Gets the number of elements in a repeated field of a protobuf message.
1.112 @@ -140,6 +150,7 @@
1.113 * @return Integer value read.
1.114 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.115 */
1.116 +#pragma deprecated use PbReadInt with index param
1.117 native PbReadRepeatedInt(Handle:pb, const String:field[], index);
1.118
1.119 /**
1.120 @@ -151,6 +162,7 @@
1.121 * @return Float value read.
1.122 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.123 */
1.124 +#pragma deprecated use PbReadFloat with index param
1.125 native Float:PbReadRepeatedFloat(Handle:pb, const String:field[], index);
1.126
1.127 /**
1.128 @@ -162,6 +174,7 @@
1.129 * @return Boolean value read.
1.130 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.131 */
1.132 +#pragma deprecated use PbReadBool with index param
1.133 native bool:PbReadRepeatedBool(Handle:pb, const String:field[], index);
1.134
1.135 /**
1.136 @@ -175,6 +188,7 @@
1.137 * @noreturn
1.138 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.139 */
1.140 +#pragma deprecated use PbReadString with index param
1.141 native PbReadRepeatedString(Handle:pb, const String:field[], index, String:buffer[], size);
1.142
1.143 /**
1.144 @@ -187,6 +201,7 @@
1.145 * @noreturn
1.146 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.147 */
1.148 +#pragma deprecated use PbReadColor with index param
1.149 native PbReadRepeatedColor(Handle:pb, const String:field[], index, buffer[4]);
1.150
1.151 /**
1.152 @@ -199,6 +214,7 @@
1.153 * @noreturn
1.154 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.155 */
1.156 +#pragma deprecated use PbReadAngle with index param
1.157 native PbReadRepeatedAngle(Handle:pb, const String:field[], index, Float:buffer[3]);
1.158
1.159 /**
1.160 @@ -211,6 +227,7 @@
1.161 * @noreturn
1.162 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.163 */
1.164 +#pragma deprecated use PbReadVector with index param
1.165 native PbReadRepeatedVector(Handle:pb, const String:field[], index, Float:buffer[3]);
1.166
1.167 /**
1.168 @@ -223,6 +240,7 @@
1.169 * @noreturn
1.170 * @error Invalid or incorrect Handle, non-existant field, or incorrect field type.
1.171 */
1.172 +#pragma deprecated use PbReadVector2D with index param
1.173 native PbReadRepeatedVector2D(Handle:pb, const String:field[], index, Float:buffer[2]);
1.174
1.175 /**